mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 00:47:42 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: 86daffa2 Fix AssertionError when player hand set to empty type
86 lines
4.3 KiB
Diff
86 lines
4.3 KiB
Diff
From 495e5af821f0288659b8814f61ced10d1c7fd210 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Thu, 6 Jun 2019 17:40:30 -0500
|
|
Subject: [PATCH] Allow color codes on signs
|
|
|
|
---
|
|
.../java/net/minecraft/server/EntityPlayer.java | 1 +
|
|
.../net/minecraft/server/PlayerConnection.java | 8 ++++++++
|
|
.../java/net/minecraft/server/TileEntitySign.java | 14 ++++++++++++++
|
|
.../java/net/pl3x/purpur/PurpurWorldConfig.java | 5 +++++
|
|
4 files changed, 28 insertions(+)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
index c747b5deb3..d5f80be598 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
@@ -1122,6 +1122,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
|
@Override
|
|
public void openSign(TileEntitySign tileentitysign) {
|
|
tileentitysign.a((EntityHuman) this);
|
|
+ if (world.purpurConfig.allowSignColors) this.playerConnection.sendPacket(tileentitysign.getTranslatedUpdatePacket()); // Purpur
|
|
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
index c9872cbd0c..03c9fc9180 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -2565,6 +2565,14 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
}
|
|
}
|
|
// Paper end
|
|
+ // Purpur start
|
|
+ if (worldserver.purpurConfig.allowSignColors) {
|
|
+ lines[i] = astring[i];
|
|
+ if (player.hasPermission("purpur.sign.color")) lines[i] = lines[i].replaceAll("(?i)&([0-9a-fr])", "\u00a7$1");
|
|
+ if (player.hasPermission("purpur.sign.style")) lines[i] = lines[i].replaceAll("(?i)&([l-or])", "\u00a7$1");
|
|
+ if (player.hasPermission("purpur.sign.magic")) lines[i] = lines[i].replaceAll("(?i)&([kr])", "\u00a7$1");
|
|
+ } else
|
|
+ // Purpur end
|
|
lines[i] = SharedConstants.a(astring[i]); //Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created.
|
|
}
|
|
SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines);
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java
|
|
index 0a8d9b52dd..65771ed9e1 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntitySign.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntitySign.java
|
|
@@ -122,6 +122,20 @@ public class TileEntitySign extends TileEntity implements ICommandListener { //
|
|
this.k[i] = null;
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ public PacketPlayOutTileEntityData getTranslatedUpdatePacket() {
|
|
+ NBTTagCompound nbt = this.b();
|
|
+ for (int i = 0; i < 4; ++i) {
|
|
+ String line = lines[i].e().replace("\u00a7", "&");
|
|
+ if (line.endsWith("&r")) {
|
|
+ line = line.substring(0, line.length() - 2);
|
|
+ }
|
|
+ nbt.setString("Text" + (i + 1), IChatBaseComponent.ChatSerializer.a(new ChatMessage(line)));
|
|
+ }
|
|
+ return new PacketPlayOutTileEntityData(position, 9, nbt);
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Nullable
|
|
@Override
|
|
public PacketPlayOutTileEntityData getUpdatePacket() {
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 8bd887b1c2..abd10a500a 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -98,4 +98,9 @@ public class PurpurWorldConfig {
|
|
private void campfiresGoOutInRain() {
|
|
campfiresGoOutInRain = getBoolean("campfires-go-out-in-rain", campfiresGoOutInRain);
|
|
}
|
|
+
|
|
+ public boolean allowSignColors = false;
|
|
+ private void allowSignColors() {
|
|
+ allowSignColors = getBoolean("allow-sign-colors", allowSignColors);
|
|
+ }
|
|
}
|
|
--
|
|
2.24.0.rc1
|
|
|