Fix vanilla scoreboard team color support for black

Fixes GH-1703
This commit is contained in:
Zach Brown 2018-11-25 12:16:01 -05:00
parent 34c1e42aa0
commit dce9007a09
No known key found for this signature in database
GPG Key ID: CC9DA35FC5450B76
8 changed files with 59 additions and 38 deletions

View File

@ -1,11 +1,18 @@
From 5cc44c28c0d182313770f065b72b9800d49c497b Mon Sep 17 00:00:00 2001
From a986d2e4dd309345b2371b063c7c8261521d0731 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 6fe3c0ea8a..cf523a3e48 100644
index 6fe3c0ea8..cf523a3e4 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -250,4 +250,9 @@ public class PaperWorldConfig {
@ -19,7 +26,7 @@ index 6fe3c0ea8a..cf523a3e48 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index e44d8372d8..4c5dc39e3a 100644
index e44d8372d..4c5dc39e3 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -2259,6 +2259,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@ -31,10 +38,10 @@ index e44d8372d8..4c5dc39e3a 100644
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 085fa8cd49..66de10ada5 100644
index 3768c4779..07b5636f0 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1638,7 +1638,15 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -1638,7 +1638,16 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
return;
}
@ -42,8 +49,9 @@ index 085fa8cd49..66de10ada5 100644
+ // Paper Start - (Meh) Support for vanilla world scoreboard name coloring
+ String displayName = event.getPlayer().getDisplayName();
+ if (this.player.getWorld().paperConfig.useVanillaScoreboardColoring) {
+ IChatBaseComponent nameFromTeam = ScoreboardTeam.a(this.player.getTeam(),((CraftPlayer) player).getHandle().getDisplayName());
+ // 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;
+ displayName = CraftChatMessage.fromComponent(nameFromTeam, EnumChatFormat.WHITE) + org.bukkit.ChatColor.RESET;
+ }
+
+ s = String.format(event.getFormat(), displayName, event.getMessage());
@ -51,6 +59,19 @@ index 085fa8cd49..66de10ada5 100644
minecraftServer.console.sendMessage(s);
if (((LazyPlayerSet) event.getRecipients()).isLazy()) {
for (Object recipient : minecraftServer.getPlayerList().players) {
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index a294b4780..0d9ac8778 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -177,7 +177,7 @@ public abstract class PlayerList {
}
chatmessage.a(EnumChatFormat.YELLOW);
- this.onPlayerJoin(entityplayer, CraftChatMessage.fromComponent(chatmessage));
+ this.onPlayerJoin(entityplayer, CraftChatMessage.fromComponent(chatmessage, EnumChatFormat.WHITE)); // Paper
// CraftBukkit end
worldserver = server.getWorldServer(entityplayer.dimension); // CraftBukkit - Update in case join event changed it
playerconnection.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
--
2.19.1

View File

@ -1,14 +1,14 @@
From 78e1e716c0acafe6e2c97883953a21155bc05bb3 Mon Sep 17 00:00:00 2001
From 07b7ccbc265b9c664e454768b74a0529fc552cc7 Mon Sep 17 00:00:00 2001
From: Brokkonaut <hannos17@gmx.de>
Date: Sun, 4 Sep 2016 16:35:43 -0500
Subject: [PATCH] Fix AIOOBE in inventory handling
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 51fe740482..931dc0e8ca 100644
index b1e5ee47e..4af93ccf5 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2102,7 +2102,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -2103,7 +2103,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
case CLONE:
if (packetplayinwindowclick.d() == 2) {
click = ClickType.MIDDLE;

View File

@ -1,4 +1,4 @@
From 0fcfb27e50a61e2c1be28fbef4784dd66019c85c Mon Sep 17 00:00:00 2001
From 522f121e122e46df441274d297e314c7efdf70b9 Mon Sep 17 00:00:00 2001
From: Alfie Cleveland <alfeh@me.com>
Date: Tue, 27 Dec 2016 01:57:57 +0000
Subject: [PATCH] Properly fix item duplication bug
@ -6,7 +6,7 @@ Subject: [PATCH] Properly fix item duplication bug
Credit to prplz for figuring out the real issue
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 891b804a6e..edef46ac31 100644
index 891b804a6..edef46ac3 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -1552,7 +1552,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@ -19,10 +19,10 @@ index 891b804a6e..edef46ac31 100644
@Override
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 0993f60e20..d7469cc547 100644
index cd8c36471..5584ef71f 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2520,7 +2520,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -2521,7 +2521,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
}
public final boolean isDisconnected() {

View File

@ -1,4 +1,4 @@
From c237475d62521c78a025e9b6d825149d665fb433 Mon Sep 17 00:00:00 2001
From 0de8dab089092d058fca863b590c4a7e03e3f738 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 16 May 2017 21:29:08 -0500
Subject: [PATCH] Add option to make parrots stay on shoulders despite movement
@ -11,7 +11,7 @@ I suspect Mojang may switch to this behavior before full release.
To be converted into a Paper-API event 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 02d99aec43..3507997fc3 100644
index 02d99aec4..3507997fc 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -361,4 +361,10 @@ public class PaperWorldConfig {
@ -26,7 +26,7 @@ index 02d99aec43..3507997fc3 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 816854dc2f..64a8c6308c 100644
index 816854dc2..64a8c6308 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -468,7 +468,7 @@ public abstract class EntityHuman extends EntityLiving {
@ -39,10 +39,10 @@ index 816854dc2f..64a8c6308c 100644
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 7ed26f6bf0..3289ba3ffd 100644
index ec58d8764..2146ef742 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1762,6 +1762,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -1763,6 +1763,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
switch (packetplayinentityaction.c()) {
case START_SNEAKING:
this.player.setSneaking(true);

View File

@ -1,4 +1,4 @@
From 8afa659bd6882b7c357345a3763d63a232f1198e Mon Sep 17 00:00:00 2001
From 09c0b959770707df93c068ef3cacca5ae30ee9a1 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Thu, 5 Oct 2017 01:54:07 +0100
Subject: [PATCH] handle PacketPlayInKeepAlive async
@ -15,10 +15,10 @@ also adding some additional logging in order to help work out what is causing
random disconnections for clients.
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index b54da4eb79..bd2693536d 100644
index 1da026fe2..0beb9f881 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2486,14 +2486,18 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -2487,14 +2487,18 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
}
public void a(PacketPlayInKeepAlive packetplayinkeepalive) {

View File

@ -1,14 +1,14 @@
From c3349109bd2f5aa374f6dee2e323468e8e79b481 Mon Sep 17 00:00:00 2001
From 42e32c7a176b27311aae7d6ac8d3614133f17f48 Mon Sep 17 00:00:00 2001
From: 0x22 <0x22@futureclient.net>
Date: Thu, 26 Apr 2018 04:41:11 -0400
Subject: [PATCH] Fix exploit that allowed colored signs to be created
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 3c9948a2d6..5bbd09aa77 100644
index aec39d8f7..e1a740cb9 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2499,7 +2499,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -2500,7 +2500,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
String[] lines = new String[4];
for (int i = 0; i < astring.length; ++i) {

View File

@ -1,4 +1,4 @@
From 01886d150f7cb93a7d3f89fa13c0b1ac3e0f2637 Mon Sep 17 00:00:00 2001
From d7d53c56a57bb21a15a31521276395893f488216 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 3 Jul 2018 21:56:23 -0400
Subject: [PATCH] InventoryCloseEvent Reason API
@ -7,7 +7,7 @@ Allows you to determine why an inventory was closed, enabling plugin developers
to "confirm" things based on if it was player triggered close or not.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 44f37f50..864691f8 100644
index 44f37f50a..864691f87 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -931,7 +931,7 @@ public class Chunk implements IChunkAccess {
@ -29,7 +29,7 @@ index 44f37f50..864691f8 100644
}
}
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 1d97a544..d510ef63 100644
index 1d97a5442..d510ef63d 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -161,7 +161,7 @@ public abstract class EntityHuman extends EntityLiving {
@ -56,7 +56,7 @@ index 1d97a544..d510ef63 100644
this.activeContainer = this.defaultContainer;
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index edef46ac..9dcf2960 100644
index edef46ac3..9dcf29609 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -347,7 +347,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@ -110,10 +110,10 @@ index edef46ac..9dcf2960 100644
this.m();
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 233e9b30..7e7e6b68 100644
index e1a740cb9..f9e6c2125 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2035,7 +2035,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -2036,7 +2036,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer());
if (this.player.isFrozen()) return; // CraftBukkit
@ -123,7 +123,7 @@ index 233e9b30..7e7e6b68 100644
this.player.m();
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index f97b5b8a..813f6d1f 100644
index 8412b153f..e9ca51d91 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -423,7 +423,7 @@ public abstract class PlayerList {
@ -136,7 +136,7 @@ index f97b5b8a..813f6d1f 100644
PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game");
cserver.getPluginManager().callEvent(playerQuitEvent);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index 70709175..c9cbf697 100644
index 707091754..c9cbf6979 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -417,8 +417,13 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@ -155,7 +155,7 @@ index 70709175..c9cbf697 100644
public boolean isBlocking() {
return getHandle().isBlocking();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 8699cc72..0f1d700c 100644
index 8699cc72f..0f1d700c7 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -740,7 +740,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@ -168,7 +168,7 @@ index 8699cc72..0f1d700c 100644
// Check if the fromWorld and toWorld are the same.
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index a7d335d3..630a43bc 100644
index a7d335d30..630a43bc4 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -998,8 +998,19 @@ public class CraftEventFactory {
@ -193,5 +193,5 @@ index a7d335d3..630a43bc 100644
human.activeContainer.transferTo(human.defaultContainer, human.getBukkitEntity());
}
--
2.17.1
2.19.1

View File

@ -1,4 +1,4 @@
From 5250252b9f15c326b4d6afb033459999ef065040 Mon Sep 17 00:00:00 2001
From 0124a7c77c02dc3feaa4e4b050cc2f762d6df5bc Mon Sep 17 00:00:00 2001
From: Minecrell <minecrell@minecrell.net>
Date: Fri, 13 Jul 2018 14:54:43 +0200
Subject: [PATCH] Refresh player inventory when cancelling
@ -16,10 +16,10 @@ Refresh the player inventory when PlayerInteractEntityEvent is
cancelled to avoid this problem.
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index fc4c1e1bf5..f7c6ead3ae 100644
index f9e6c2125..ff03755bc 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1949,6 +1949,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -1950,6 +1950,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
}
if (event.isCancelled()) {