From 564cb998610b0b5051785524f488ee8344d163d4 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Fri, 29 Mar 2019 15:01:52 -0400 Subject: [PATCH] Add Player#getGameProfile() to make tab list plugins easier to make. --- .../main/java/com/velocitypowered/api/proxy/Player.java | 5 +++++ .../proxy/connection/backend/LoginSessionHandler.java | 2 +- .../connection/backend/VelocityServerConnection.java | 8 ++++---- .../proxy/connection/client/ClientPlaySessionHandler.java | 3 +-- .../proxy/connection/client/ConnectedPlayer.java | 3 ++- 5 files changed, 13 insertions(+), 8 deletions(-) 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 8aa9870b1..21e22221f 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/Player.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/Player.java @@ -106,6 +106,11 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage */ void setGameProfileProperties(List properties); + /** + * Returns the player's game profile. + */ + GameProfile getGameProfile(); + /** * Sets the tab list header and footer for the player. * 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 0a0d24371..3f92556ff 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 @@ -72,7 +72,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler { response.setId(packet.getId()); response.setData(createForwardingData(configuration.getForwardingSecret(), serverConn.getPlayer().getRemoteAddress().getHostString(), - serverConn.getPlayer().getProfile())); + serverConn.getPlayer().getGameProfile())); mc.write(response); informationForwarded = true; } else { 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 99a88c706..90dd6f90c 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 @@ -126,9 +126,9 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation, .append('\0') .append(proxyPlayer.getRemoteAddress().getHostString()) .append('\0') - .append(proxyPlayer.getProfile().getUndashedId()) + .append(proxyPlayer.getGameProfile().getUndashedId()) .append('\0'); - GSON.toJson(proxyPlayer.getProfile().getProperties(), data); + GSON.toJson(proxyPlayer.getGameProfile().getProperties(), data); return data.toString(); } @@ -192,8 +192,8 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation, @Override public String toString() { - return "[server connection] " + proxyPlayer.getProfile().getName() + " -> " + registeredServer - .getServerInfo().getName(); + return "[server connection] " + proxyPlayer.getGameProfile().getName() + " -> " + + registeredServer.getServerInfo().getName(); } @Override diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index fe10746d6..86bd810ce 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -109,8 +109,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { return false; } } catch (Exception e) { - logger - .info("Exception occurred while running command for {}", player.getProfile().getName(), + logger.info("Exception occurred while running command for {}", player.getUsername(), e); player.sendMessage( TextComponent.of("An error occurred while running this command.", TextColor.RED)); 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 f69422380..3d5fadd04 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 @@ -114,7 +114,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { return Optional.ofNullable(connectedServer); } - public GameProfile getProfile() { + @Override + public GameProfile getGameProfile() { return profile; }