From 777059d652f5b4cf79bc0c5e40da5749f20bab24 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 13 Mar 2023 09:54:09 +0100 Subject: [PATCH] Change read type of Teams packet display name --- .../api/data/VBMappingDataLoader.java | 1 + .../packets/PlayerPacket1_13.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/data/VBMappingDataLoader.java b/common/src/main/java/com/viaversion/viabackwards/api/data/VBMappingDataLoader.java index ab957483..52c30be8 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/data/VBMappingDataLoader.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/data/VBMappingDataLoader.java @@ -63,6 +63,7 @@ public final class VBMappingDataLoader { return packedData; } + ViaBackwards.getPlatform().getLogger().info("Loading " + name + " from plugin folder"); try { final CompoundTag fileData = NBTIO.readFile(file, false, false); return mergeTags(packedData, fileData); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java index 7ea324b1..c9bebd98 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java @@ -219,18 +219,18 @@ public class PlayerPacket1_13 extends RewriterBase { protocol.registerClientbound(ClientboundPackets1_13.TEAMS, new PacketHandlers() { @Override public void register() { - map(Type.STRING); - map(Type.BYTE); + map(Type.STRING); // Name + map(Type.BYTE); // Action handler(wrapper -> { byte action = wrapper.get(Type.BYTE, 0); if (action == 0 || action == 2) { - String displayName = wrapper.read(Type.STRING); - displayName = ChatRewriter.jsonToLegacyText(displayName); - displayName = ChatUtil.removeUnusedColor(displayName, 'f'); - if (displayName.length() > 32) { - displayName = displayName.substring(0, 32); + JsonElement displayName = wrapper.read(Type.COMPONENT); + String legacyTextDisplayName = displayName == null || displayName.isJsonNull() ? "" : ChatRewriter.jsonToLegacyText(displayName.toString()); + legacyTextDisplayName = ChatUtil.removeUnusedColor(legacyTextDisplayName, 'f'); + if (legacyTextDisplayName.length() > 32) { + legacyTextDisplayName = legacyTextDisplayName.substring(0, 32); } - wrapper.write(Type.STRING, displayName); + wrapper.write(Type.STRING, legacyTextDisplayName); byte flags = wrapper.read(Type.BYTE); String nameTagVisibility = wrapper.read(Type.STRING);