From e849c51daa955744289a820859282190224600ee Mon Sep 17 00:00:00 2001 From: Riley Park Date: Wed, 10 Mar 2021 11:09:23 -0800 Subject: [PATCH] fix #5336 --- ...nilla-per-world-scoreboard-coloring-.patch | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Spigot-Server-Patches/0083-Option-to-use-vanilla-per-world-scoreboard-coloring-.patch b/Spigot-Server-Patches/0083-Option-to-use-vanilla-per-world-scoreboard-coloring-.patch index ba0205e283..a9b745c339 100644 --- a/Spigot-Server-Patches/0083-Option-to-use-vanilla-per-world-scoreboard-coloring-.patch +++ b/Spigot-Server-Patches/0083-Option-to-use-vanilla-per-world-scoreboard-coloring-.patch @@ -26,20 +26,40 @@ index db2dddd12f54e6d15916c4cee623676541de37fb..1942f5224aaebb18adb591d6f70a419c + } } diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -index f5a24b82b902498bb52eeb11fa351391b3adb31e..de39a489d7a8f9c8731c2ffbbaea500979575056 100644 +index 8767c84e6417888cacf1ed76c7e3def73f873d70..7a5ac38c490f5b886a0611b01bd36053bc54a85a 100644 --- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -@@ -16,7 +16,9 @@ import net.kyori.adventure.text.format.TextDecoration; +@@ -11,12 +11,14 @@ import java.util.regex.Pattern; + import net.kyori.adventure.text.Component; + import net.kyori.adventure.text.TextReplacementConfig; + import net.kyori.adventure.text.event.ClickEvent; +-import net.kyori.adventure.text.format.Style; +-import net.kyori.adventure.text.format.TextDecoration; import net.minecraft.server.EntityPlayer; import net.minecraft.server.IChatBaseComponent; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.ScoreboardTeam; ++import net.minecraft.server.ScoreboardTeamBase; import org.bukkit.Bukkit; ++import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.util.LazyPlayerSet; import org.bukkit.craftbukkit.util.Waitable; -@@ -108,6 +110,9 @@ public final class ChatProcessor { +@@ -104,10 +106,22 @@ public final class ChatProcessor { + } + + private static String legacyDisplayName(final CraftPlayer player) { ++ if (((CraftWorld) player.getWorld()).getHandle().paperConfig.useVanillaScoreboardColoring) { ++ final EntityPlayer ep = player.getHandle(); ++ IChatBaseComponent name = ep.getDisplayName(); ++ final ScoreboardTeamBase team = ep.getScoreboardTeam(); ++ if (team != null) { ++ name = team.getFormattedName(name); ++ } ++ return PaperAdventure.LEGACY_SECTION_UXRC.serialize(PaperAdventure.asAdventure(name)) + ChatColor.RESET; ++ } + return player.getDisplayName(); } private static Component displayName(final CraftPlayer player) {