mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: 01b965e0 Fix getChunkAtIfCachedImmediately (#2915) 0a897d6e Rebuild patches 5792c862 Updated Upstream (Bukkit/CraftBukkit/Spigot) c9eebbb8 Fix Player#applyMending NPE (#2917) d16a5d88 Performance patches prerequisite (#2802)
86 lines
4.3 KiB
Diff
86 lines
4.3 KiB
Diff
From 370e0d0af302dfdcc30802a93f7b24d8a7a10bab 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 15230a834c..5e56e0e3e8 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
@@ -1124,6 +1124,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 a1ce2d2e07..213f7992dc 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -2575,6 +2575,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 5eb86c4341..8810a1120b 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntitySign.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntitySign.java
|
|
@@ -119,6 +119,20 @@ public class TileEntitySign extends TileEntity implements ICommandListener { //
|
|
this.g[i] = null;
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ public PacketPlayOutTileEntityData getTranslatedUpdatePacket() {
|
|
+ NBTTagCompound nbt = this.b();
|
|
+ for (int i = 0; i < 4; ++i) {
|
|
+ String line = lines[i].getLegacyString().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 6cb887ca8b..061b02e45a 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -95,4 +95,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
|
|
|