From 15d064461725175f50a5d8c8cc37fa1293ef15eb Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 10 May 2021 20:47:51 -0700 Subject: [PATCH] Fix incorrect colors in some log messages (#5609) CraftChatMessage.fromComponent fails to take into account the style of TranslatableComponent args, causing any styling on args to be completely ignored. Fixing this is relatively simple, however would cause behavior to deviate from upstream. This commit will fix the coloring in messages logged through MinecraftServer.LOGGER by simply using Adventure's legacy text serializer, which properly serializes TranslatableComponents and their arguments. Note that this doesn't do anything about the underlying issue of CraftChatMessage.fromComponent improperly serializing TranslatableComponents. --- Spigot-Server-Patches/EntityMoveEvent.patch | 4 ++-- ...minalConsoleAppender-for-console-improvements.patch | 10 +++++++++- Spigot-Server-Patches/misc-debugging-dumps.patch | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Spigot-Server-Patches/EntityMoveEvent.patch b/Spigot-Server-Patches/EntityMoveEvent.patch index 433ba97efd..6453240840 100644 --- a/Spigot-Server-Patches/EntityMoveEvent.patch +++ b/Spigot-Server-Patches/EntityMoveEvent.patch @@ -8,10 +8,10 @@ diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -0,0 +0,0 @@ import com.mojang.datafixers.DataFixer; - import io.netty.buffer.ByteBuf; +@@ -0,0 +0,0 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; + import io.papermc.paper.adventure.PaperAdventure; // Paper +import io.papermc.paper.event.entity.EntityMoveEvent; import it.unimi.dsi.fastutil.longs.LongIterator; import java.awt.image.BufferedImage; diff --git a/Spigot-Server-Patches/Use-TerminalConsoleAppender-for-console-improvements.patch b/Spigot-Server-Patches/Use-TerminalConsoleAppender-for-console-improvements.patch index 3b8e01fc1d..c39bcbe698 100644 --- a/Spigot-Server-Patches/Use-TerminalConsoleAppender-for-console-improvements.patch +++ b/Spigot-Server-Patches/Use-TerminalConsoleAppender-for-console-improvements.patch @@ -146,6 +146,14 @@ diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -0,0 +0,0 @@ import com.mojang.datafixers.DataFixer; + import io.netty.buffer.ByteBuf; + import io.netty.buffer.ByteBufOutputStream; + import io.netty.buffer.Unpooled; ++import io.papermc.paper.adventure.PaperAdventure; // Paper + import it.unimi.dsi.fastutil.longs.LongIterator; + import java.awt.image.BufferedImage; + import java.io.BufferedWriter; @@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger; import com.mojang.serialization.DynamicOps; import com.mojang.serialization.Lifecycle; @@ -197,7 +205,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid) { - MinecraftServer.LOGGER.info(ichatbasecomponent.getString()); -+ MinecraftServer.LOGGER.info(org.bukkit.craftbukkit.util.CraftChatMessage.fromComponent(ichatbasecomponent));// Paper - Log message with colors ++ MinecraftServer.LOGGER.info(PaperAdventure.LEGACY_SECTION_UXRC.serialize(PaperAdventure.asAdventure(ichatbasecomponent))); // Paper - Log message with colors } public KeyPair getKeyPair() { diff --git a/Spigot-Server-Patches/misc-debugging-dumps.patch b/Spigot-Server-Patches/misc-debugging-dumps.patch index 3ea1fb5006..1947d7ed92 100644 --- a/Spigot-Server-Patches/misc-debugging-dumps.patch +++ b/Spigot-Server-Patches/misc-debugging-dumps.patch @@ -32,9 +32,9 @@ diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -0,0 +0,0 @@ import io.netty.buffer.ByteBuf; - import io.netty.buffer.ByteBufOutputStream; +@@ -0,0 +0,0 @@ import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; + import io.papermc.paper.adventure.PaperAdventure; // Paper import io.papermc.paper.event.entity.EntityMoveEvent; +import io.papermc.paper.util.TraceUtil; import it.unimi.dsi.fastutil.longs.LongIterator;