From 1fe6f0bff77569efdd20ba50c892177e83098697 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sat, 12 Mar 2022 18:47:04 -0700 Subject: [PATCH] Fix colors in some console messages --- ...pport-for-hex-color-codes-in-console.patch | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/patches/server/Add-support-for-hex-color-codes-in-console.patch b/patches/server/Add-support-for-hex-color-codes-in-console.patch index b68aca5e87..bf7bf78956 100644 --- a/patches/server/Add-support-for-hex-color-codes-in-console.patch +++ b/patches/server/Add-support-for-hex-color-codes-in-console.patch @@ -32,19 +32,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.kyori.adventure.audience.MessageType; +import net.kyori.adventure.identity.Identity; +import net.kyori.adventure.text.Component; -+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.bukkit.craftbukkit.command.CraftConsoleCommandSender; -@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.command.CraftConsoleCommandSender; - public class TerminalConsoleCommandSender extends CraftConsoleCommandSender { - - private static final Logger LOGGER = LogManager.getRootLogger(); -+ private static final LegacyComponentSerializer SERIALIZER = LegacyComponentSerializer.builder() -+ .hexColors() -+ .flattener(PaperAdventure.FLATTENER) -+ .character(HexFormattingConverter.COLOR_CHAR) -+ .build(); +@@ -0,0 +0,0 @@ public class TerminalConsoleCommandSender extends CraftConsoleCommandSender { @Override public void sendRawMessage(String message) { @@ -56,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public void sendMessage(Identity identity, Component message, MessageType type) { -+ LOGGER.info(SERIALIZER.serialize(message)); ++ LOGGER.info(HexFormattingConverter.SERIALIZER.serialize(message)); } } @@ -69,8 +60,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package io.papermc.paper.console; + +import com.destroystokyo.paper.PaperConfig; ++import io.papermc.paper.adventure.PaperAdventure; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextColor; ++import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import net.minecrell.terminalconsole.TerminalConsoleAppender; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.config.Configuration; @@ -103,7 +96,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static final String ANSI_RESET = "\u001B[m"; + -+ public static final char COLOR_CHAR = 0x7f; ++ private static final char COLOR_CHAR = 0x7f; ++ public static final LegacyComponentSerializer SERIALIZER = LegacyComponentSerializer.builder() ++ .hexColors() ++ .flattener(PaperAdventure.FLATTENER) ++ .character(HexFormattingConverter.COLOR_CHAR) ++ .build(); + private static final String LOOKUP = "0123456789abcdefklmnor"; + + private static final String RGB_ANSI = "\u001B[38;2;%d;%d;%dm"; @@ -271,6 +269,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + +} +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +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 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop