2022-06-07 19:15:06 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc>
Date: Tue, 8 Mar 2016 18:28:43 -0800
Subject: [PATCH] Don't nest if we don't need to when cerealising text
components
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
2022-06-07 23:49:14 +00:00
index cfcdb21f48f74ea1638907e966f06c4aee072d34..365cf8486d690029a48b771a6186118a28eba7d4 100644
2022-06-07 19:15:06 +00:00
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
2022-06-07 23:49:14 +00:00
@@ -16,7 +16,7 @@ public record ClientboundSystemChatPacket(@javax.annotation.Nullable net.kyori.a
2022-06-07 19:15:06 +00:00
}
public ClientboundSystemChatPacket(net.md_5.bungee.api.chat.BaseComponent[] content, int typeId) {
2022-06-07 23:49:14 +00:00
- this(null, net.md_5.bungee.chat.ComponentSerializer.toString(content), typeId); // Paper - Adventure
+ this(null, improveBungeeComponentSerialization(content), typeId); // Paper - Adventure & don't nest if we don't need to so that we can preserve formatting
}
// Spigot end
// Paper start
@@ -27,6 +27,14 @@ public record ClientboundSystemChatPacket(@javax.annotation.Nullable net.kyori.a
public ClientboundSystemChatPacket(net.kyori.adventure.text.Component content, int typeId) {
this(content, null, typeId);
}
2022-06-07 19:15:06 +00:00
+
2022-06-07 23:49:14 +00:00
+ private static String improveBungeeComponentSerialization(net.md_5.bungee.api.chat.BaseComponent[] content) {
2022-06-07 19:15:06 +00:00
+ if (content.length == 1) {
+ return net.md_5.bungee.chat.ComponentSerializer.toString(content[0]);
+ } else {
+ return net.md_5.bungee.chat.ComponentSerializer.toString(content);
+ }
2022-06-07 23:49:14 +00:00
+ }
2022-06-07 19:15:06 +00:00
// Paper end
2022-06-07 23:49:14 +00:00
public ClientboundSystemChatPacket(FriendlyByteBuf buf) {