From 8e509e017951e4b640af4a78a645de146c252d5b Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 27 Mar 2023 10:19:23 -0700 Subject: [PATCH] Fix chat messages being logged without formatting to console (#9058) --- patches/server/Adventure.patch | 25 +++++++++++++++++++ ...-possibility-for-getServer-singleton.patch | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index e32d01bff3..cb2cce3e2f 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -2117,6 +2117,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 org.bukkit.craftbukkit.SpigotTimings; // Spigot + public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTask> implements CommandSource, AutoCloseable { + + public static final Logger LOGGER = LogUtils.getLogger(); ++ public static final net.kyori.adventure.text.logger.slf4j.ComponentLogger COMPONENT_LOGGER = net.kyori.adventure.text.logger.slf4j.ComponentLogger.logger(LOGGER.getName()); // Paper + public static final String VANILLA_BRAND = "vanilla"; + private static final float AVERAGE_TICK_TIME_SMOOTHING = 0.8F; + private static final int TICK_STATS_SPAN = 100; @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa private boolean allowFlight; @Nullable @@ -2153,6 +2161,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public boolean isStopped() { @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa + } + + public void logChatMessage(Component message, ChatType.Bound params, @Nullable String prefix) { +- String s1 = params.decorate(message).getString(); ++ // Paper start ++ net.kyori.adventure.text.Component s1 = io.papermc.paper.adventure.PaperAdventure.asAdventure(params.decorate(message)); + + if (prefix != null) { +- MinecraftServer.LOGGER.info("[{}] {}", prefix, s1); ++ MinecraftServer.COMPONENT_LOGGER.info("[{}] {}", prefix, s1); + } else { +- MinecraftServer.LOGGER.info("{}", s1); ++ MinecraftServer.COMPONENT_LOGGER.info("{}", s1); ++ // Paper end + } + + } // CraftBukkit start public final java.util.concurrent.ExecutorService chatExecutor = java.util.concurrent.Executors.newCachedThreadPool( diff --git a/patches/server/remove-null-possibility-for-getServer-singleton.patch b/patches/server/remove-null-possibility-for-getServer-singleton.patch index 52159675ba..934cff6303 100644 --- a/patches/server/remove-null-possibility-for-getServer-singleton.patch +++ b/patches/server/remove-null-possibility-for-getServer-singleton.patch @@ -15,8 +15,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private static MinecraftServer SERVER; // Paper public static final Logger LOGGER = LogUtils.getLogger(); + public static final net.kyori.adventure.text.logger.slf4j.ComponentLogger COMPONENT_LOGGER = net.kyori.adventure.text.logger.slf4j.ComponentLogger.logger(LOGGER.getName()); // Paper public static final String VANILLA_BRAND = "vanilla"; - private static final float AVERAGE_TICK_TIME_SMOOTHING = 0.8F; @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa public MinecraftServer(OptionSet options, WorldLoader.DataLoadContext worldLoader, Thread thread, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, ChunkProgressListenerFactory worldloadlistenerfactory) {