From 1649b53e54e710650eb21fe127235fddc187f7ef 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 | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch b/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch index c6966768ac..a7d9c298d7 100644 --- a/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch +++ b/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch @@ -29,12 +29,19 @@ 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.format.TextDecoration; +@@ -0,0 +0,0 @@ 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; @@ -42,6 +49,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ 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) { + if (((CraftWorld) player.getWorld()).getHandle().paperConfig.useVanillaScoreboardColoring) { + return PaperAdventure.asAdventure(ScoreboardTeam.a(player.getHandle().getScoreboardTeam(), player.getHandle().getDisplayName()));