Use ChatRenderer.defaultRenderer() when legacy events have not modified the format (#6104)

This commit is contained in:
Jason Penilla 2021-10-13 04:00:40 -05:00
parent 55ca8ebefe
commit 871bc4e895
2 changed files with 5 additions and 4 deletions

View File

@ -162,6 +162,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ })
+ .build();
+ // copied from adventure-text-serializer-legacy -->
+ private static final String DEFAULT_LEGACY_FORMAT = "<%1$s> %2$s"; // copied from PlayerChatEvent/AsyncPlayerChatEvent
+ final MinecraftServer server;
+ final ServerPlayer player;
+ final String message;
@ -316,6 +317,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ private static ChatRenderer legacyRenderer(final String format) {
+ if (DEFAULT_LEGACY_FORMAT.equals(format)) {
+ return ChatRenderer.defaultRenderer();
+ }
+ return ChatRenderer.viewerUnaware((player, displayName, message) -> PaperAdventure.LEGACY_SECTION_UXRC.deserialize(String.format(format, legacyDisplayName((CraftPlayer) player), PaperAdventure.LEGACY_SECTION_UXRC.serialize(message))).replaceText(URL_REPLACEMENT_CONFIG));
+ }
+

View File

@ -29,12 +29,9 @@ diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/m
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
+++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
@@ -0,0 +0,0 @@ import net.kyori.adventure.text.TextReplacementConfig;
import net.kyori.adventure.text.event.ClickEvent;
@@ -0,0 +0,0 @@ import net.kyori.adventure.text.event.ClickEvent;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.world.scores.PlayerTeam;
+import net.minecraft.world.scores.Team;
import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.CraftWorld;