diff options
Diffstat (limited to 'patches/server')
-rw-r--r-- | patches/server/0008-Adventure.patch | 32 | ||||
-rw-r--r-- | patches/server/0596-Add-support-for-hex-color-codes-in-console.patch | 41 |
2 files changed, 66 insertions, 7 deletions
diff --git a/patches/server/0008-Adventure.patch b/patches/server/0008-Adventure.patch index c721cded2e..cbacc69eba 100644 --- a/patches/server/0008-Adventure.patch +++ b/patches/server/0008-Adventure.patch @@ -788,6 +788,31 @@ index 0000000000000000000000000000000000000000..2a08e0461db4e699b7e6a1558a4419c8 + return net.minecraft.network.chat.Component.Serializer.fromJson(GsonComponentSerializer.gson().serializer().toJsonTree(component)); + } +} +diff --git a/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java b/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java +new file mode 100644 +index 0000000000000000000000000000000000000000..c3631efda9c7fa531a8a9f18fbee7b5f8655382b +--- /dev/null ++++ b/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java +@@ -0,0 +1,19 @@ ++package io.papermc.paper.adventure.providers; ++ ++import io.papermc.paper.adventure.PaperAdventure; ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.logger.slf4j.ComponentLogger; ++import net.kyori.adventure.text.logger.slf4j.ComponentLoggerProvider; ++import org.jetbrains.annotations.NotNull; ++import org.slf4j.LoggerFactory; ++ ++public class ComponentLoggerProviderImpl implements ComponentLoggerProvider { ++ @Override ++ public @NotNull ComponentLogger logger(@NotNull LoggerHelper helper, @NotNull String name) { ++ return helper.delegating(LoggerFactory.getLogger(name), this::serialize); ++ } ++ ++ private String serialize(final Component message) { ++ return PaperAdventure.asPlain(message, null); ++ } ++} diff --git a/src/main/java/io/papermc/paper/adventure/providers/GsonComponentSerializerProviderImpl.java b/src/main/java/io/papermc/paper/adventure/providers/GsonComponentSerializerProviderImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..c620d5aa2b0208b769dbe9563f0e99edc9a91047 @@ -3680,6 +3705,13 @@ index 838d5b877c01be3ef353f434d98e27b46c0a3fb4..5c4c0ba05f10d2d83b22d3e86805cfa8 HashSet<Player> reference = new HashSet<Player>(players.size()); for (ServerPlayer player : players) { reference.add(player.getBukkitEntity()); +diff --git a/src/main/resources/META-INF/services/net.kyori.adventure.text.logger.slf4j.ComponentLoggerProvider b/src/main/resources/META-INF/services/net.kyori.adventure.text.logger.slf4j.ComponentLoggerProvider +new file mode 100644 +index 0000000000000000000000000000000000000000..399bde6e57cd82b50d3ebe0f51a3958fa2d52d43 +--- /dev/null ++++ b/src/main/resources/META-INF/services/net.kyori.adventure.text.logger.slf4j.ComponentLoggerProvider +@@ -0,0 +1 @@ ++io.papermc.paper.adventure.providers.ComponentLoggerProviderImpl diff --git a/src/main/resources/META-INF/services/net.kyori.adventure.text.minimessage.MiniMessage$Provider b/src/main/resources/META-INF/services/net.kyori.adventure.text.minimessage.MiniMessage$Provider new file mode 100644 index 0000000000000000000000000000000000000000..6ce632b6c9dc5e4b3b978331df51c0ffd1526471 diff --git a/patches/server/0596-Add-support-for-hex-color-codes-in-console.patch b/patches/server/0596-Add-support-for-hex-color-codes-in-console.patch index 5a7a286607..9e65cb76e8 100644 --- a/patches/server/0596-Add-support-for-hex-color-codes-in-console.patch +++ b/patches/server/0596-Add-support-for-hex-color-codes-in-console.patch @@ -21,35 +21,62 @@ index 1adbceadd5df96e17796561a40eb7b760493440e..c07257314e070d4423c4f53f58cb0962 public static boolean allowBlockPermanentBreakingExploits = false; diff --git a/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java b/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java -index 685deaa0e5d1ddc13e3a7c0471b1cfcf1710c869..709f2a420ceaffe0101c676ec23e949e8d684465 100644 +index 685deaa0e5d1ddc13e3a7c0471b1cfcf1710c869..8f07539a82f449ad217e316a7513a1708781fb63 100644 --- a/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java +++ b/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java -@@ -1,5 +1,10 @@ +@@ -1,16 +1,25 @@ package com.destroystokyo.paper.console; -+import io.papermc.paper.console.HexFormattingConverter; +import net.kyori.adventure.audience.MessageType; +import net.kyori.adventure.identity.Identity; +import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.logger.slf4j.ComponentLogger; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +-import org.apache.logging.log4j.Logger; import org.bukkit.craftbukkit.command.CraftConsoleCommandSender; -@@ -10,8 +15,13 @@ public class TerminalConsoleCommandSender extends CraftConsoleCommandSender { + + public class TerminalConsoleCommandSender extends CraftConsoleCommandSender { + +- private static final Logger LOGGER = LogManager.getRootLogger(); ++ private static final ComponentLogger LOGGER = ComponentLogger.logger(LogManager.getRootLogger().getName()); @Override public void sendRawMessage(String message) { - // TerminalConsoleAppender supports color codes directly in log messages -- LOGGER.info(message); + final Component msg = LegacyComponentSerializer.legacySection().deserialize(message); + this.sendMessage(Identity.nil(), msg, MessageType.SYSTEM); + } + + @Override + public void sendMessage(Identity identity, Component message, MessageType type) { -+ LOGGER.info(HexFormattingConverter.SERIALIZER.serialize(message)); + LOGGER.info(message); } +diff --git a/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java b/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java +index c3631efda9c7fa531a8a9f18fbee7b5f8655382b..9a3c1314d5a0aa20380662595359580b1a97be89 100644 +--- a/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java ++++ b/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java +@@ -1,9 +1,11 @@ + package io.papermc.paper.adventure.providers; + +-import io.papermc.paper.adventure.PaperAdventure; ++import io.papermc.paper.console.HexFormattingConverter; ++import java.util.Locale; + import net.kyori.adventure.text.Component; + import net.kyori.adventure.text.logger.slf4j.ComponentLogger; + import net.kyori.adventure.text.logger.slf4j.ComponentLoggerProvider; ++import net.kyori.adventure.translation.GlobalTranslator; + import org.jetbrains.annotations.NotNull; + import org.slf4j.LoggerFactory; + +@@ -14,6 +16,6 @@ public class ComponentLoggerProviderImpl implements ComponentLoggerProvider { + } + + private String serialize(final Component message) { +- return PaperAdventure.asPlain(message, null); ++ return HexFormattingConverter.SERIALIZER.serialize(GlobalTranslator.render(message, Locale.getDefault())); + } } diff --git a/src/main/java/io/papermc/paper/console/HexFormattingConverter.java b/src/main/java/io/papermc/paper/console/HexFormattingConverter.java new file mode 100644 |