mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 17:07:43 +01:00
86 lines
4.3 KiB
Diff
86 lines
4.3 KiB
Diff
From 9cb17aad55df0f36335066132488c86a802cfdae 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 7801879c8..e0e94ca11 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
@@ -1120,6 +1120,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 e7b8b2e99..3405e8a85 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -2561,6 +2561,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 0a8d9b52d..65771ed9e 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 383e7d5d5..fe0136c63 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.23.0.rc1
|
|
|