Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/patches/server/0057-Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch

36 Zeilen
1.8 KiB
Diff

2022-06-07 21:15:06 +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/ClientboundSystemChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
2022-06-08 01:49:14 +02:00
index cfcdb21f48f74ea1638907e966f06c4aee072d34..365cf8486d690029a48b771a6186118a28eba7d4 100644
2022-06-07 21:15:06 +02: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-08 01:49:14 +02:00
@@ -16,7 +16,7 @@ public record ClientboundSystemChatPacket(@javax.annotation.Nullable net.kyori.a
2022-06-07 21:15:06 +02:00
}
public ClientboundSystemChatPacket(net.md_5.bungee.api.chat.BaseComponent[] content, int typeId) {
2022-06-08 01:49:14 +02: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 21:15:06 +02:00
+
2022-06-08 01:49:14 +02:00
+ private static String improveBungeeComponentSerialization(net.md_5.bungee.api.chat.BaseComponent[] content) {
2022-06-07 21:15:06 +02: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-08 01:49:14 +02:00
+ }
2022-06-07 21:15:06 +02:00
// Paper end
2022-06-08 01:49:14 +02:00
public ClientboundSystemChatPacket(FriendlyByteBuf buf) {