Paper/Spigot-Server-Patches/0099-Option-to-use-vanilla-per-world-scoreboard-coloring-.patch
Aikar 76e1e4d79f
Update Upstream
Removed my ChunkLoadEvent patch as upstream fixed it
2018-07-30 01:08:59 -04:00

57 lines
3.1 KiB
Diff

From c43b466a7fb9981256385d2d6c1bd6abc75e743e 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
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 667a0dde8c..b6ef1d4378 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -239,4 +239,9 @@ public class PaperWorldConfig {
keepLoadedRange = (short) (getInt("keep-spawn-loaded-range", Math.min(spigotConfig.viewDistance, 8)) * 16);
log( "Keep Spawn Loaded Range: " + (keepLoadedRange/16));
}
+
+ public boolean useVanillaScoreboardColoring;
+ private void useVanillaScoreboardColoring() {
+ useVanillaScoreboardColoring = getBoolean("use-vanilla-world-scoreboard-name-coloring", false);
+ }
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 1f2981529e..f694463d20 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -2252,6 +2252,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return this.getFlag(5);
}
+ @Nullable public ScoreboardTeamBase getTeam() { return this.be(); } // Paper - OBFHELPER
@Nullable
public ScoreboardTeamBase be() {
if (!this.world.paperConfig.nonPlayerEntitiesOnScoreboards && !(this instanceof EntityHuman)) { return null; } // Paper
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 90ab7f065f..1ca3c87c7a 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1622,7 +1622,15 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
return;
}
- s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
+ // Paper Start - (Meh) Support for vanilla world scoreboard name coloring
+ String displayName = event.getPlayer().getDisplayName();
+ if (this.player.getWorld().paperConfig.useVanillaScoreboardColoring) {
+ // Explicitly add a RESET here, vanilla uses components for this now...
+ displayName = CraftChatMessage.fromComponent(ScoreboardTeam.a(this.player.getTeam(),((CraftPlayer) player).getHandle().getDisplayName())) + org.bukkit.ChatColor.RESET;
+ }
+
+ s = String.format(event.getFormat(), displayName, event.getMessage());
+ // Paper end
minecraftServer.console.sendMessage(s);
if (((LazyPlayerSet) event.getRecipients()).isLazy()) {
for (Object recipient : minecraftServer.getPlayerList().players) {
--
2.18.0