3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-24 15:20:19 +01:00

Change read type of Teams packet display name

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-03-13 09:54:09 +01:00
Ursprung fc565f8cd5
Commit 777059d652
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
2 geänderte Dateien mit 9 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -63,6 +63,7 @@ public final class VBMappingDataLoader {
return packedData; return packedData;
} }
ViaBackwards.getPlatform().getLogger().info("Loading " + name + " from plugin folder");
try { try {
final CompoundTag fileData = NBTIO.readFile(file, false, false); final CompoundTag fileData = NBTIO.readFile(file, false, false);
return mergeTags(packedData, fileData); return mergeTags(packedData, fileData);

Datei anzeigen

@ -219,18 +219,18 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
protocol.registerClientbound(ClientboundPackets1_13.TEAMS, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_13.TEAMS, new PacketHandlers() {
@Override @Override
public void register() { public void register() {
map(Type.STRING); map(Type.STRING); // Name
map(Type.BYTE); map(Type.BYTE); // Action
handler(wrapper -> { handler(wrapper -> {
byte action = wrapper.get(Type.BYTE, 0); byte action = wrapper.get(Type.BYTE, 0);
if (action == 0 || action == 2) { if (action == 0 || action == 2) {
String displayName = wrapper.read(Type.STRING); JsonElement displayName = wrapper.read(Type.COMPONENT);
displayName = ChatRewriter.jsonToLegacyText(displayName); String legacyTextDisplayName = displayName == null || displayName.isJsonNull() ? "" : ChatRewriter.jsonToLegacyText(displayName.toString());
displayName = ChatUtil.removeUnusedColor(displayName, 'f'); legacyTextDisplayName = ChatUtil.removeUnusedColor(legacyTextDisplayName, 'f');
if (displayName.length() > 32) { if (legacyTextDisplayName.length() > 32) {
displayName = displayName.substring(0, 32); legacyTextDisplayName = legacyTextDisplayName.substring(0, 32);
} }
wrapper.write(Type.STRING, displayName); wrapper.write(Type.STRING, legacyTextDisplayName);
byte flags = wrapper.read(Type.BYTE); byte flags = wrapper.read(Type.BYTE);
String nameTagVisibility = wrapper.read(Type.STRING); String nameTagVisibility = wrapper.read(Type.STRING);