From cae142b85d8777ca2c7d5db11c427d6ff802b9ad Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 22 Feb 2021 22:43:49 -0800 Subject: [PATCH] Enable Hex colors on PaperAdventure.LEGACY_SECTION_UXRC, and use it for sending messages to console command sender (#5230) This fixes messages to console having colors stripped, and also fixes colors being downsampled in PlayerConnection#disconnect(String) --- Spigot-Server-Patches/0010-Adventure.patch | 8 ++++---- ...83-Add-option-for-console-having-all-permissions.patch | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Spigot-Server-Patches/0010-Adventure.patch b/Spigot-Server-Patches/0010-Adventure.patch index a91b382cab..7881a2c73b 100644 --- a/Spigot-Server-Patches/0010-Adventure.patch +++ b/Spigot-Server-Patches/0010-Adventure.patch @@ -186,7 +186,7 @@ index 0000000000000000000000000000000000000000..64fcc77eb2ce8979ae756696d98f1d3a +} diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java new file mode 100644 -index 0000000000000000000000000000000000000000..09b1b569893111f4a02811a5ba9d4a176ea8f6bc +index 0000000000000000000000000000000000000000..23e6a033612d964f1185dd09a10b470f46685568 --- /dev/null +++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java @@ -0,0 +1,286 @@ @@ -224,7 +224,7 @@ index 0000000000000000000000000000000000000000..09b1b569893111f4a02811a5ba9d4a17 + +public final class PaperAdventure { + public static final AttributeKey LOCALE_ATTRIBUTE = AttributeKey.valueOf("adventure:locale"); -+ public static final LegacyComponentSerializer LEGACY_SECTION_UXRC = LegacyComponentSerializer.builder().useUnusualXRepeatedCharacterHexFormat().build(); ++ public static final LegacyComponentSerializer LEGACY_SECTION_UXRC = LegacyComponentSerializer.builder().hexColors().useUnusualXRepeatedCharacterHexFormat().build(); + static final GsonComponentSerializer GSON = GsonComponentSerializer.builder() + .legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.INSTANCE) + .build(); @@ -1731,7 +1731,7 @@ index 81f6bf5533288ed90e2f1f4d421d54195d9650c7..352c8e58418db5e293b179ab801b513f IChatBaseComponent[] components = new IChatBaseComponent[4]; diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java -index 089fe4a3458ed3106fa214f89a7004a5d3c6bb95..5bb8c38c511ec000476afde8038587ddbc7549cc 100644 +index 089fe4a3458ed3106fa214f89a7004a5d3c6bb95..8495632d99137b89e4dd4543c2ea721dacfc9ee2 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java @@ -80,4 +80,11 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co @@ -1742,7 +1742,7 @@ index 089fe4a3458ed3106fa214f89a7004a5d3c6bb95..5bb8c38c511ec000476afde8038587dd + // Paper start + @Override + public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) { -+ this.sendRawMessage(net.kyori.adventure.text.serializer.plain.PlainComponentSerializer.plain().serialize(message)); ++ this.sendRawMessage(io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(message)); + } + // Paper end } diff --git a/Spigot-Server-Patches/0483-Add-option-for-console-having-all-permissions.patch b/Spigot-Server-Patches/0483-Add-option-for-console-having-all-permissions.patch index f907561451..57458b9139 100644 --- a/Spigot-Server-Patches/0483-Add-option-for-console-having-all-permissions.patch +++ b/Spigot-Server-Patches/0483-Add-option-for-console-having-all-permissions.patch @@ -19,12 +19,12 @@ index 5b5edd2aed9cf76535104df65783bfd1d5bb7c85..456e6363758c41e1d58e178bf839e96a + } diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java -index 5bb8c38c511ec000476afde8038587ddbc7549cc..b1e95feb2e106627cf935d2894354c2cc28f0d77 100644 +index 8495632d99137b89e4dd4543c2ea721dacfc9ee2..971be15ebe4c156a36d7315a6d6c3a8e4e09d5db 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java @@ -86,5 +86,15 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) { - this.sendRawMessage(net.kyori.adventure.text.serializer.plain.PlainComponentSerializer.plain().serialize(message)); + this.sendRawMessage(io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(message)); } + + @Override