13
0
geforkt von Mirrors/Paper
Paper/patches/server/0057-Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch
2022-03-11 21:13:46 +01:00

28 Zeilen
1.5 KiB
Diff

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/ClientboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java
index f4f52e43852d2b0b56770c3f747a655a3a6dd683..8b0d452b12d5eca1f92e2cdf014118e215407b31 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java
@@ -36,7 +36,14 @@ public class ClientboundChatPacket implements Packet<ClientGamePacketListener> {
// Paper end
// Spigot start
if (this.components != null) {
- buf.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(components));
+ // buf.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(components)); // Paper - comment, replaced with below
+ // Paper start - don't nest if we don't need to so that we can preserve formatting
+ if (this.components.length == 1) {
+ buf.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(this.components[0]));
+ } else {
+ buf.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(this.components));
+ }
+ // Paper end
} else {
buf.writeComponent(this.message);
}