67 lines
3.3 KiB
Diff
67 lines
3.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
|
Date: Wed, 6 Apr 2016 01:04:23 -0500
|
|
Subject: [PATCH] Option to use vanilla per-world scoreboard coloring on names
|
|
|
|
This change is basically a bandaid to fix CB's complete and utter lack
|
|
of support for vanilla scoreboard name modifications.
|
|
|
|
In the future, finding a way to merge the vanilla expectations in with
|
|
bukkit's concept of a display name would be preferable. There was a PR
|
|
for this on CB at one point but I can't find it. We may need to do this
|
|
ourselves at some point in the future.
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
index db2dddd12f54e6d15916c4cee623676541de37fb..1942f5224aaebb18adb591d6f70a419cfc1a7bdd 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -254,4 +254,9 @@ public class PaperWorldConfig {
|
|
grassUpdateRate = Math.max(0, getInt("grass-spread-tick-rate", grassUpdateRate));
|
|
log("Grass Spread Tick Rate: " + grassUpdateRate);
|
|
}
|
|
+
|
|
+ public boolean useVanillaScoreboardColoring;
|
|
+ private void useVanillaScoreboardColoring() {
|
|
+ useVanillaScoreboardColoring = getBoolean("use-vanilla-world-scoreboard-name-coloring", false);
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
|
index 75c36e772be93c9808cd8b72410ad8baa3d47006..636c60c7a8d674150fad0579c642cd037debde28 100644
|
|
--- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
|
+++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
|
@@ -16,7 +16,11 @@ import net.kyori.adventure.text.event.ClickEvent;
|
|
import net.minecraft.network.chat.IChatBaseComponent;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.level.EntityPlayer;
|
|
+import net.minecraft.world.scores.ScoreboardTeam;
|
|
+import net.minecraft.world.scores.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;
|
|
@@ -178,10 +182,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) {
|
|
+ if (((CraftWorld) player.getWorld()).getHandle().paperConfig.useVanillaScoreboardColoring) {
|
|
+ return PaperAdventure.asAdventure(ScoreboardTeam.a(player.getHandle().getScoreboardTeam(), player.getHandle().getDisplayName()));
|
|
+ }
|
|
return player.displayName();
|
|
}
|
|
|