From f34b5ac2fcae5d004522da9a02e5787b8600c36f Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Wed, 22 Jul 2020 11:18:46 -0400 Subject: [PATCH] Yet another breaking change in the Adventure API --- .../proxy/connection/backend/BungeeCordMessageResponder.java | 4 ++-- .../proxy/connection/client/ConnectedPlayer.java | 4 ++-- .../proxy/connection/client/InitialInboundConnection.java | 2 +- .../com/velocitypowered/proxy/console/VelocityConsole.java | 2 +- .../proxy/protocol/packet/LegacyDisconnect.java | 4 ++-- .../velocitypowered/proxy/protocol/packet/PlayerListItem.java | 3 ++- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java index 500be28ef..cb7eb6657 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java @@ -138,7 +138,7 @@ class BungeeCordMessageResponder { } private void processMessage(ByteBufDataInput in) { - processMessage0(in, LegacyComponentSerializer.legacy()); + processMessage0(in, LegacyComponentSerializer.legacySection()); } private void processMessageRaw(ByteBufDataInput in) { @@ -210,7 +210,7 @@ class BungeeCordMessageResponder { private void processKick(ByteBufDataInput in) { proxy.getPlayer(in.readUTF()).ifPresent(player -> { String kickReason = in.readUTF(); - player.disconnect(LegacyComponentSerializer.legacy().deserialize(kickReason)); + player.disconnect(LegacyComponentSerializer.legacySection().deserialize(kickReason)); }); } 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 407658528..3876ca91c 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 @@ -273,7 +273,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { // Due to issues with action bar packets, we'll need to convert the text message into a // legacy message and then inject the legacy text into a component... yuck! JsonObject object = new JsonObject(); - object.addProperty("text", LegacyComponentSerializer.legacy().serialize(message)); + object.addProperty("text", LegacyComponentSerializer.legacySection().serialize(message)); Chat chat = new Chat(); chat.setMessage(object.toString()); chat.setType((byte) 1); @@ -391,7 +391,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { */ public void disconnect0(Component reason, boolean duringLogin) { logger.info("{} has disconnected: {}", this, - LegacyComponentSerializer.legacy().serialize(reason)); + LegacyComponentSerializer.legacySection().serialize(reason)); connection.closeWith(Disconnect.create(reason, this.getProtocolVersion())); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java index 44a6829dc..7b5295693 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java @@ -60,7 +60,7 @@ public final class InitialInboundConnection implements InboundConnection, */ public void disconnect(Component reason) { logger.info("{} has disconnected: {}", this, - LegacyComponentSerializer.legacy().serialize(reason)); + LegacyComponentSerializer.legacySection().serialize(reason)); connection.closeWith(Disconnect.create(reason, getProtocolVersion())); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java b/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java index 4468122ff..ab4ad3873 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java @@ -39,7 +39,7 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons @Override public void sendMessage(net.kyori.adventure.text.@NonNull Component message) { - logger.info(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacy() + logger.info(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection() .serialize(message)); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyDisconnect.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyDisconnect.java index 43b58b614..0a8d7bba5 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyDisconnect.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyDisconnect.java @@ -48,7 +48,7 @@ public class LegacyDisconnect { LEGACY_COLOR_CODE + "1", Integer.toString(response.getVersion().getProtocol()), response.getVersion().getName(), - getFirstLine(LegacyComponentSerializer.legacy().serialize(response + getFirstLine(LegacyComponentSerializer.legacySection().serialize(response .getDescriptionComponent())), Integer.toString(players.getOnline()), Integer.toString(players.getMax()) @@ -74,7 +74,7 @@ public class LegacyDisconnect { */ public static LegacyDisconnect from(TextComponent component) { // We intentionally use the legacy serializers, because the old clients can't understand JSON. - String serialized = LegacyComponentSerializer.legacy().serialize(component); + String serialized = LegacyComponentSerializer.legacySection().serialize(component); return new LegacyDisconnect(serialized); } 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 3c58c3196..d0717bf43 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 @@ -127,7 +127,8 @@ public class PlayerListItem implements MinecraftPacket { } else { Item item = items.get(0); if (item.getDisplayName() != null) { - String displayName = LegacyComponentSerializer.legacy().serialize(item.getDisplayName()); + String displayName = LegacyComponentSerializer.legacySection() + .serialize(item.getDisplayName()); ProtocolUtils.writeString(buf, displayName.length() > 16 ? displayName.substring(0, 16) : displayName); } else {