Paper/patches/server/0055-Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch

28 lines
1.5 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02: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/ClientboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java
2021-06-12 02:57:04 +02:00
index 1f5050e6c1d932aa196ab9524f7f1f9bd1b45fce..a64780b4b49d01322d8f755ff540a9622c89e983 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java
2021-06-12 02:57:04 +02:00
@@ -36,7 +36,14 @@ public class ClientboundChatPacket implements Packet<ClientGamePacketListener> {
2021-06-11 14:02:28 +02:00
// Paper end
// Spigot start
2021-06-12 02:57:04 +02:00
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
2021-06-11 14:02:28 +02:00
+ // Paper start - don't nest if we don't need to so that we can preserve formatting
+ if (this.components.length == 1) {
2021-06-12 02:57:04 +02:00
+ buf.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(this.components[0]));
2021-06-11 14:02:28 +02:00
+ } else {
2021-06-12 02:57:04 +02:00
+ buf.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(this.components));
2021-06-11 14:02:28 +02:00
+ }
+ // Paper end
} else {
buf.writeComponent(this.message);
}