From 04fbd54c3bf33cf892d57db883e8bd429ee7bddf Mon Sep 17 00:00:00 2001 From: Mariell Hoversholm Date: Sat, 27 Feb 2021 12:02:06 +0100 Subject: [PATCH] fix: legacy component serialisation was wiped out When merging 2e419805adb39737676aed19b22c259e70672707, nobody caught the fact we removed the component serialisation of legacy BungeeCord Chat API components in the PacketPlayOutTitle class. Test plugin code: ```kotlin class LegacyMessageCommand : BaseCommand() { override fun register(manager: PaperCommandManager) { manager.command(manager.commandBuilder("legacymsg") .sender() .handler { val component = ComponentBuilder("Test") .color(ChatColor.DARK_RED) .bold(true) .append(" message") .bold(false) .color(ChatColor.of("#f8a8a8")) .event( HoverEvent( HoverEvent.Action.SHOW_TEXT, Text( ComponentBuilder("Test hover") .color(ChatColor.AQUA) .underlined(true) .create() ) ) ) .event( ClickEvent( ClickEvent.Action.SUGGEST_COMMAND, "/legacymsg" ) ) .create() it.sender.sendMessage(*component) it.sender.sendActionBar(*component) it.sender.sendTitle( Title.builder() .title(component) .subtitle(component) .fadeIn(40) .stay(60) .fadeOut(40) .build() ) }) } } ``` Fixes GH-5271. --- .../Player-Tab-List-and-Title-APIs.patch | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Spigot-Server-Patches/Player-Tab-List-and-Title-APIs.patch b/Spigot-Server-Patches/Player-Tab-List-and-Title-APIs.patch index f07de5f652..0d7b2a2f86 100644 --- a/Spigot-Server-Patches/Player-Tab-List-and-Title-APIs.patch +++ b/Spigot-Server-Patches/Player-Tab-List-and-Title-APIs.patch @@ -16,6 +16,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Nullable public static IChatMutableComponent a(String s) { return (IChatMutableComponent) ChatDeserializer.a(IChatBaseComponent.ChatSerializer.a, s, IChatMutableComponent.class, false); +diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java ++++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java +@@ -0,0 +0,0 @@ public class PacketDataSerializer extends ByteBuf { + public PacketDataSerializer writeComponent(final net.kyori.adventure.text.Component component) { + return this.writeUtf(PaperAdventure.asJsonString(component, this.adventure$locale), 262144); + } ++ ++ @Deprecated ++ public PacketDataSerializer writeComponent(final net.md_5.bungee.api.chat.BaseComponent[] component) { ++ return this.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(component), 262144); ++ } + // Paper end + + public PacketDataSerializer a(IChatBaseComponent ichatbasecomponent) { diff --git a/src/main/java/net/minecraft/server/PacketPlayOutTitle.java b/src/main/java/net/minecraft/server/PacketPlayOutTitle.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/PacketPlayOutTitle.java @@ -38,6 +54,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void b(PacketDataSerializer packetdataserializer) throws IOException { +@@ -0,0 +0,0 @@ public class PacketPlayOutTitle implements Packet { + // Paper start + if (this.adventure$text != null) { + packetdataserializer.writeComponent(this.adventure$text); ++ } else if (this.components != null) { ++ packetdataserializer.writeComponent(this.components); + } else + // Paper end + packetdataserializer.a(this.b); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java