mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
fix: legacy component serialisation was wiped out
When merging 2e419805ad
, 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<CommandSender>) {
manager.command(manager.commandBuilder("legacymsg")
.sender<Player>()
.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.
This commit is contained in:
parent
31433b07f6
commit
04fbd54c3b
1 changed files with 25 additions and 0 deletions
|
@ -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<PacketListenerPlayOut> {
|
||||
// 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
|
||||
|
|
Loading…
Reference in a new issue