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 d9147c7a4..996808ee0 100644 --- a/api/src/main/java/com/velocitypowered/api/util/GameProfile.java +++ b/api/src/main/java/com/velocitypowered/api/util/GameProfile.java @@ -48,31 +48,69 @@ public final class GameProfile implements Identifiable { return properties; } - public GameProfile setUniqueId(UUID id) { + /** + * Creates a new {@code GameProfile} with the specified unique id. + * + * @param id the new unique id + * @return the new {@code GameProfile} + */ + public GameProfile withUniqueId(UUID id) { return new GameProfile(Preconditions.checkNotNull(id, "id"), UuidUtils.toUndashed(id), this.name, this.properties); } - public GameProfile setUndashedId(String undashedId) { + /** + * Creates a new {@code GameProfile} with the specified undashed id. + * + * @param undashedId the new undashed id + * @return the new {@code GameProfile} + */ + public GameProfile withUndashedId(String undashedId) { return new GameProfile( UuidUtils.fromUndashed(Preconditions.checkNotNull(undashedId, "undashedId")), undashedId, this.name, this.properties); } - public GameProfile setName(String name) { + /** + * Creates a new {@code GameProfile} with the specified name. + * + * @param name the new name + * @return the new {@code GameProfile} + */ + public GameProfile withName(String name) { return new GameProfile(this.id, this.undashedId, Preconditions.checkNotNull(name, "name"), this.properties); } - public GameProfile setProperties(List properties) { + /** + * Creates a new {@code GameProfile} with the specified properties. + * + * @param properties the new properties + * @return the new {@code GameProfile} + */ + public GameProfile withProperties(List properties) { return new GameProfile(this.id, this.undashedId, this.name, ImmutableList.copyOf(properties)); } + /** + * Creates a new {@code GameProfile} with the properties of this object plus the specified + * properties. + * + * @param properties the properties to add + * @return the new {@code GameProfile} + */ public GameProfile addProperties(Iterable properties) { return new GameProfile(this.id, this.undashedId, this.name, ImmutableList.builder().addAll(this.properties).addAll(properties).build()); } + /** + * Creates a new {@code GameProfile} with the properties of this object plus the specified + * property. + * + * @param property the property to add + * @return the new {@code GameProfile} + */ public GameProfile addProperty(Property property) { return new GameProfile(this.id, this.undashedId, this.name, ImmutableList.builder().addAll(this.properties).add(property).build()); diff --git a/api/src/main/java/com/velocitypowered/api/util/Identifiable.java b/api/src/main/java/com/velocitypowered/api/util/Identifiable.java index 8235e5267..a35e81b4f 100644 --- a/api/src/main/java/com/velocitypowered/api/util/Identifiable.java +++ b/api/src/main/java/com/velocitypowered/api/util/Identifiable.java @@ -7,5 +7,10 @@ import java.util.UUID; */ public interface Identifiable { - UUID getUniqueId(); + /** + * Returns the {@code UUID} attached to this object. + * + * @return the UUID + */ + UUID getUniqueId(); } 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 81f2d1209..54be8b618 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 @@ -212,7 +212,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { @Override public void setGameProfileProperties(List properties) { - this.profile = profile.setProperties(Preconditions.checkNotNull(properties)); + this.profile = profile.withProperties(Preconditions.checkNotNull(properties)); } @Override