From d2b4b771347369969fa3728d851f0f6193e597cc Mon Sep 17 00:00:00 2001 From: Leymooo Date: Tue, 11 Sep 2018 19:00:34 +0300 Subject: [PATCH] Allow to edit GameProfile properties. --- .../com/velocitypowered/api/proxy/Player.java | 18 ++++++++++++++++++ .../connection/client/ConnectedPlayer.java | 13 ++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) 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 0ebb1fdfa..821ed0587 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/Player.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/Player.java @@ -5,7 +5,9 @@ import com.velocitypowered.api.proxy.player.PlayerSettings; import com.velocitypowered.api.proxy.messages.ChannelMessageSink; import com.velocitypowered.api.proxy.messages.ChannelMessageSource; import com.velocitypowered.api.proxy.server.ServerInfo; +import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.api.util.MessagePosition; +import java.util.List; import net.kyori.text.Component; import org.checkerframework.checker.nullness.qual.NonNull; @@ -34,6 +36,10 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage */ Optional getCurrentServer(); + /** + * Returns the player settings + * @return the settings + */ PlayerSettings getPlayerSettings(); /** @@ -64,6 +70,18 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage */ ConnectionRequestBuilder createConnectionRequest(@NonNull ServerInfo info); + /** + * Gets a game profile properties of player + * @return a immutable list of properties + */ + List getGameProfileProperties(); + + /** + * Sets a GameProfile properties({@link GameProfile.Property) + * @param properties a properties to set + */ + void setGameProfileProperties(List properties); + /** * Sets the tab list header and footer for the player. * @param header the header component 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 605a376d3..1fb951dea 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 @@ -54,7 +54,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { private final MinecraftConnection connection; private final InetSocketAddress virtualHost; - private final GameProfile profile; + private GameProfile profile; private PermissionFunction permissionFunction = null; private int tryIndex = 0; private long ping = -1; @@ -162,6 +162,17 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { public ConnectionRequestBuilder createConnectionRequest(@NonNull ServerInfo info) { return new ConnectionRequestBuilderImpl(info); } + + @Override + public List getGameProfileProperties() { + return this.profile.getProperties(); + } + + @Override + public void setGameProfileProperties(List properties) { + Preconditions.checkNotNull(properties); + this.profile = new GameProfile(profile.getId(), profile.getName(), properties); + } @Override public void setHeaderAndFooter(@NonNull Component header, @NonNull Component footer) {