diff --git a/api/src/main/java/com/velocitypowered/api/proxy/Player.java b/api/src/main/java/com/velocitypowered/api/proxy/Player.java index d046db850..ce8a8c4b1 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/Player.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/Player.java @@ -7,7 +7,6 @@ import com.velocitypowered.api.proxy.player.PlayerSettings; import com.velocitypowered.api.proxy.player.TabList; import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.util.GameProfile; -import com.velocitypowered.api.util.Identifiable; import com.velocitypowered.api.util.MessagePosition; import com.velocitypowered.api.util.ModInfo; import com.velocitypowered.api.util.title.Title; @@ -20,7 +19,7 @@ import net.kyori.text.Component; * Represents a player who is connected to the proxy. */ public interface Player extends CommandSource, InboundConnection, ChannelMessageSource, - ChannelMessageSink, Identifiable { + ChannelMessageSink { /** * Returns the player's current username. @@ -29,6 +28,14 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage */ String getUsername(); + + /** + * Returns the player's UUID. + * + * @return the UUID + */ + UUID getUniqueId(); + /** * Returns the server that the player is currently connected to. * diff --git a/api/src/main/java/com/velocitypowered/api/util/GameProfile.java b/api/src/main/java/com/velocitypowered/api/util/GameProfile.java index 996808ee0..015cdae97 100644 --- a/api/src/main/java/com/velocitypowered/api/util/GameProfile.java +++ b/api/src/main/java/com/velocitypowered/api/util/GameProfile.java @@ -8,7 +8,7 @@ import java.util.UUID; /** * Represents a Mojang game profile. This class is immutable. */ -public final class GameProfile implements Identifiable { +public final class GameProfile { private final UUID id; private final String undashedId, name; @@ -31,13 +31,12 @@ public final class GameProfile implements Identifiable { this.properties = properties; } - @Override - public UUID getUniqueId() { - return this.id; + public String getId() { + return undashedId; } - public String getUndashedId() { - return this.undashedId; + public UUID idAsUuid() { + return id; } public String getName() { @@ -54,7 +53,7 @@ public final class GameProfile implements Identifiable { * @param id the new unique id * @return the new {@code GameProfile} */ - public GameProfile withUniqueId(UUID id) { + public GameProfile withUuid(UUID id) { return new GameProfile(Preconditions.checkNotNull(id, "id"), UuidUtils.toUndashed(id), this.name, this.properties); } @@ -65,7 +64,7 @@ public final class GameProfile implements Identifiable { * @param undashedId the new undashed id * @return the new {@code GameProfile} */ - public GameProfile withUndashedId(String undashedId) { + public GameProfile withId(String undashedId) { return new GameProfile( UuidUtils.fromUndashed(Preconditions.checkNotNull(undashedId, "undashedId")), undashedId, this.name, this.properties); diff --git a/api/src/main/java/com/velocitypowered/api/util/Identifiable.java b/api/src/main/java/com/velocitypowered/api/util/Identifiable.java deleted file mode 100644 index a35e81b4f..000000000 --- a/api/src/main/java/com/velocitypowered/api/util/Identifiable.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.velocitypowered.api.util; - -import java.util.UUID; - -/** - * Represents an object that can be identified by its UUID - */ -public interface Identifiable { - - /** - * Returns the {@code UUID} attached to this object. - * - * @return the UUID - */ - UUID getUniqueId(); -} diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java index 603a2190c..4ab39ecca 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java @@ -157,7 +157,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler { try { ProtocolUtils.writeVarInt(dataToForward, VelocityConstants.FORWARDING_VERSION); ProtocolUtils.writeString(dataToForward, address); - ProtocolUtils.writeUuid(dataToForward, profile.getUniqueId()); + ProtocolUtils.writeUuid(dataToForward, profile.idAsUuid()); ProtocolUtils.writeString(dataToForward, profile.getName()); ProtocolUtils.writeProperties(dataToForward, profile.getProperties()); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java index aff20854c..7ee3804b6 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java @@ -109,7 +109,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation, .append('\0') .append(proxyPlayer.getRemoteAddress().getHostString()) .append('\0') - .append(proxyPlayer.getProfile().getUndashedId()) + .append(proxyPlayer.getProfile().getId()) .append('\0'); GSON.toJson(proxyPlayer.getProfile().getProperties(), data); return data.toString(); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index 54be8b618..a57d7ff69 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -100,7 +100,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { @Override public UUID getUniqueId() { - return profile.getUniqueId(); + return profile.idAsUuid(); } @Override diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PlayerListItem.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PlayerListItem.java index 4a67bdbdf..a389ed085 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PlayerListItem.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PlayerListItem.java @@ -142,7 +142,7 @@ public class PlayerListItem implements MinecraftPacket { } public static Item from(TabListEntry entry) { - return new Item(entry.getProfile().getUniqueId()) + return new Item(entry.getProfile().idAsUuid()) .setName(entry.getProfile().getName()) .setProperties(entry.getProfile().getProperties()) .setLatency(entry.getLatency()) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/GameProfileSerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/GameProfileSerializer.java index 600312b90..da4de84ba 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/GameProfileSerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/GameProfileSerializer.java @@ -29,7 +29,7 @@ public class GameProfileSerializer implements JsonSerializer, @Override public JsonElement serialize(GameProfile src, Type typeOfSrc, JsonSerializationContext context) { JsonObject obj = new JsonObject(); - obj.add("id", new JsonPrimitive(src.getUndashedId())); + obj.add("id", new JsonPrimitive(src.getId())); obj.add("name", new JsonPrimitive(src.getName())); obj.add("properties", context.serialize(src.getProperties(), propertyList)); return obj; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java index 0b6b90e1a..4e084d61e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java @@ -45,13 +45,13 @@ public class VelocityTabList implements TabList { Preconditions.checkNotNull(entry, "entry"); Preconditions.checkArgument(entry.getTabList().equals(this), "The provided entry was not created by this tab list"); - Preconditions.checkArgument(!entries.containsKey(entry.getProfile().getUniqueId()), + Preconditions.checkArgument(!entries.containsKey(entry.getProfile().idAsUuid()), "this TabList already contains an entry with the same uuid"); PlayerListItem.Item packetItem = PlayerListItem.Item.from(entry); connection.write( new PlayerListItem(PlayerListItem.ADD_PLAYER, Collections.singletonList(packetItem))); - entries.put(entry.getProfile().getUniqueId(), entry); + entries.put(entry.getProfile().idAsUuid(), entry); } @Override @@ -141,7 +141,7 @@ public class VelocityTabList implements TabList { } void updateEntry(int action, TabListEntry entry) { - if (entries.containsKey(entry.getProfile().getUniqueId())) { + if (entries.containsKey(entry.getProfile().idAsUuid())) { PlayerListItem.Item packetItem = PlayerListItem.Item.from(entry); connection.write(new PlayerListItem(action, Collections.singletonList(packetItem))); }