diff options
author | Josh Roy <[email protected]> | 2022-06-12 21:29:04 -0400 |
---|---|---|
committer | Josh Roy <[email protected]> | 2022-06-12 22:01:46 -0400 |
commit | 38c13b27c946c1b468512f599e258fd4a5df0f4c (patch) | |
tree | 21a75aeb4181382e1b1008dac34d3f5cfd5da49e | |
parent | 3925a53dd0fbe6bb99c15228b618dddd67017dcd (diff) | |
download | Paper-38c13b27c946c1b468512f599e258fd4a5df0f4c.tar.gz Paper-38c13b27c946c1b468512f599e258fd4a5df0f4c.zip |
Update Adventure to 4.11.0 and implement ComponentLogger
-rw-r--r-- | patches/api/0005-Adventure.patch | 27 | ||||
-rw-r--r-- | patches/api/0026-Use-ASM-for-event-executors.patch | 6 | ||||
-rw-r--r-- | patches/api/0069-Allow-plugins-to-use-SLF4J-for-logging.patch | 14 | ||||
-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 |
5 files changed, 99 insertions, 21 deletions
diff --git a/patches/api/0005-Adventure.patch b/patches/api/0005-Adventure.patch index 98f21f2bc8..4d1e2fdc7c 100644 --- a/patches/api/0005-Adventure.patch +++ b/patches/api/0005-Adventure.patch @@ -7,14 +7,14 @@ Co-authored-by: zml <[email protected]> Co-authored-by: Jake Potrebic <[email protected]> diff --git a/build.gradle.kts b/build.gradle.kts -index 98afa6a25131dc626ea7a5122f33df6bd2d39178..eefc024acc3e14ae21855df7f2f358bd1e0a9e38 100644 +index 98afa6a25131dc626ea7a5122f33df6bd2d39178..fc37b3ef788b43d5523e8af416f8dbb6387ec92e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -8,18 +8,37 @@ java { +@@ -8,18 +8,38 @@ java { withJavadocJar() } -+val adventureVersion = "4.10.1" ++val adventureVersion = "4.11.0" +val apiAndDocs: Configuration by configurations.creating { + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION)) @@ -46,10 +46,11 @@ index 98afa6a25131dc626ea7a5122f33df6bd2d39178..eefc024acc3e14ae21855df7f2f358bd + apiAndDocs("net.kyori:adventure-text-serializer-gson") + apiAndDocs("net.kyori:adventure-text-serializer-legacy") + apiAndDocs("net.kyori:adventure-text-serializer-plain") ++ apiAndDocs("net.kyori:adventure-text-logger-slf4j") // Paper end compileOnly("org.apache.maven:maven-resolver-provider:3.8.4") -@@ -77,9 +96,24 @@ tasks.withType<Javadoc> { +@@ -77,9 +97,24 @@ tasks.withType<Javadoc> { "https://guava.dev/releases/31.0.1-jre/api/docs/", "https://javadoc.io/doc/org.yaml/snakeyaml/1.30/", "https://javadoc.io/doc/org.jetbrains/annotations/23.0.0/", // Paper - we don't want Java 5 annotations @@ -3976,6 +3977,24 @@ index 228421154913116069c20323afb519bdde2134df..26791db3c267670d5782f1d2b67ff7d5 + } + // Paper end } +diff --git a/src/main/java/org/bukkit/plugin/Plugin.java b/src/main/java/org/bukkit/plugin/Plugin.java +index 03ca87a1cbace2459174bb7bb8847bda766e80c5..b37938745f916b5f0111b07b1a1c97527f026e9d 100644 +--- a/src/main/java/org/bukkit/plugin/Plugin.java ++++ b/src/main/java/org/bukkit/plugin/Plugin.java +@@ -179,6 +179,13 @@ public interface Plugin extends TabExecutor { + @NotNull + public Logger getLogger(); + ++ // Paper start - Adventure component logger ++ @NotNull ++ default net.kyori.adventure.text.logger.slf4j.ComponentLogger getComponentLogger() { ++ return net.kyori.adventure.text.logger.slf4j.ComponentLogger.logger(getLogger().getName()); ++ } ++ // Paper end ++ + /** + * Returns the name of the plugin. + * <p> diff --git a/src/main/java/org/bukkit/scoreboard/Objective.java b/src/main/java/org/bukkit/scoreboard/Objective.java index ff3fcb2697eb00736238d0efdcaefe43043334d3..75acd6f8f3d774bb79e8e513125e801c5569a244 100644 --- a/src/main/java/org/bukkit/scoreboard/Objective.java diff --git a/patches/api/0026-Use-ASM-for-event-executors.patch b/patches/api/0026-Use-ASM-for-event-executors.patch index 4851ec4874..94b4fddc14 100644 --- a/patches/api/0026-Use-ASM-for-event-executors.patch +++ b/patches/api/0026-Use-ASM-for-event-executors.patch @@ -6,13 +6,13 @@ Subject: [PATCH] Use ASM for event executors. Uses method handles for private or static methods. diff --git a/build.gradle.kts b/build.gradle.kts -index 19b65a9b56b73f873ef646d14a6cf091b69d3873..bc6f68a0cadeec865401e9cb0dce89460484b148 100644 +index fc37b3ef788b43d5523e8af416f8dbb6387ec92e..677a6d377bcc5ed5db32601073a0a90c74100786 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -39,6 +39,9 @@ dependencies { - apiAndDocs("net.kyori:adventure-text-serializer-gson") +@@ -40,6 +40,9 @@ dependencies { apiAndDocs("net.kyori:adventure-text-serializer-legacy") apiAndDocs("net.kyori:adventure-text-serializer-plain") + apiAndDocs("net.kyori:adventure-text-logger-slf4j") + + implementation("org.ow2.asm:asm:9.2") + implementation("org.ow2.asm:asm-commons:9.2") diff --git a/patches/api/0069-Allow-plugins-to-use-SLF4J-for-logging.patch b/patches/api/0069-Allow-plugins-to-use-SLF4J-for-logging.patch index 4f28c52220..fbffe0262c 100644 --- a/patches/api/0069-Allow-plugins-to-use-SLF4J-for-logging.patch +++ b/patches/api/0069-Allow-plugins-to-use-SLF4J-for-logging.patch @@ -14,25 +14,25 @@ it without having to shade it in the plugin and going through several layers of logging abstraction. diff --git a/build.gradle.kts b/build.gradle.kts -index bc6f68a0cadeec865401e9cb0dce89460484b148..d6c4abc30af2b535644707a240b60d1b613785e9 100644 +index 677a6d377bcc5ed5db32601073a0a90c74100786..46016bd1a2403c9f449ba92ec942cd349da747ac 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -39,6 +39,8 @@ dependencies { - apiAndDocs("net.kyori:adventure-text-serializer-gson") +@@ -40,6 +40,8 @@ dependencies { apiAndDocs("net.kyori:adventure-text-serializer-legacy") apiAndDocs("net.kyori:adventure-text-serializer-plain") + apiAndDocs("net.kyori:adventure-text-logger-slf4j") + api("org.apache.logging.log4j:log4j-api:2.17.1") + api("org.slf4j:slf4j-api:1.8.0-beta4") implementation("org.ow2.asm:asm:9.2") implementation("org.ow2.asm:asm-commons:9.2") diff --git a/src/main/java/org/bukkit/plugin/Plugin.java b/src/main/java/org/bukkit/plugin/Plugin.java -index 03ca87a1cbace2459174bb7bb8847bda766e80c5..34438b5362b0ba0949625d81e8371fe0d1f76fdf 100644 +index b37938745f916b5f0111b07b1a1c97527f026e9d..08aef59d8443038771704d9587e31f299e587307 100644 --- a/src/main/java/org/bukkit/plugin/Plugin.java +++ b/src/main/java/org/bukkit/plugin/Plugin.java -@@ -179,6 +179,22 @@ public interface Plugin extends TabExecutor { - @NotNull - public Logger getLogger(); +@@ -186,6 +186,22 @@ public interface Plugin extends TabExecutor { + } + // Paper end + // Paper start - Add SLF4J/Log4J loggers + @NotNull 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 |