From 5cceebdffc1c3c076ee444ce4ce75bf8a6c4cca9 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Thu, 6 Aug 2020 15:13:22 -0400 Subject: [PATCH] Read PlayerListItem display names according to the protocol version. Fixes #349 --- .../proxy/protocol/packet/PlayerListItem.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 d0717bf43..c21a513e9 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 @@ -58,7 +58,7 @@ public class PlayerListItem implements MinecraftPacket { item.setProperties(ProtocolUtils.readProperties(buf)); item.setGameMode(ProtocolUtils.readVarInt(buf)); item.setLatency(ProtocolUtils.readVarInt(buf)); - item.setDisplayName(readOptionalComponent(buf)); + item.setDisplayName(readOptionalComponent(buf, version)); break; case UPDATE_GAMEMODE: item.setGameMode(ProtocolUtils.readVarInt(buf)); @@ -67,7 +67,7 @@ public class PlayerListItem implements MinecraftPacket { item.setLatency(ProtocolUtils.readVarInt(buf)); break; case UPDATE_DISPLAY_NAME: - item.setDisplayName(readOptionalComponent(buf)); + item.setDisplayName(readOptionalComponent(buf, version)); break; case REMOVE_PLAYER: //Do nothing, all that is needed is the uuid @@ -85,9 +85,10 @@ public class PlayerListItem implements MinecraftPacket { } } - private static @Nullable Component readOptionalComponent(ByteBuf buf) { + private static @Nullable Component readOptionalComponent(ByteBuf buf, ProtocolVersion version) { if (buf.readBoolean()) { - return GsonComponentSerializer.gson().deserialize(ProtocolUtils.readString(buf)); + return ProtocolUtils.getJsonChatSerializer(version) + .deserialize(ProtocolUtils.readString(buf)); } return null; }