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.
This commit is contained in:
Jason Penilla 2021-05-10 20:47:51 -07:00
parent 693926c32d
commit 15d0644617
3 changed files with 13 additions and 5 deletions

View file

@ -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;

View file

@ -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() {

View file

@ -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;