Files
Purpur/patches/server/0045-Signs-allow-color-codes.patch
BillyGalbreath e53522571d Updated Upstream (Paper & Tuinity)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
808bd9198 Add fast alternative constructor for Vector3f (#5339)
e849c51da fix #5336
0b25bacfc fix patch 'Remove streams from SensorNearest' (fixes #5330)
4d287e31c Use Adventure for `/version` command feedback, add copy to clipboard click event (#5333)

Tuinity Changes:
5b6d8beec: Update Upstream (Paper)
81d5fc1dd: Fix NPE in pickup logic for arrow
19ac6608f: Move region chunk unload & poi unload hook up
38ad5a1bd: Do not run close logic for inventories on chunk load
fb75a6f83: Do not allow the server to unload chunks at request of plugins
f87cb795f: Make entity tracker use highest range of passengers
71b089f18: Do not run raytrace logic for AIR
09e1a1036: Fix NPE in light exception handler
0ae7c2c23: Dump even more info for ticking entities
2e4a930c4: Store changed positions inside field on light engine
7734ef0a9: Detail player ticking in watchdog dumps
2021-03-11 15:01:23 -06:00

85 lines
4.9 KiB
Diff

From 0000000000000000000000000000000000000000 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] Signs allow color codes
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 20aaf52d500d208857f87b1a99e77489607018b2..0cfe1a620fdd1d4e1240413fb8340b9118bbaa5e 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -1449,6 +1449,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@Override
public void openSign(TileEntitySign tileentitysign) {
+ if (world.purpurConfig.signAllowColors) this.playerConnection.sendPacket(tileentitysign.getTranslatedUpdatePacket()); // Purpur
tileentitysign.a((EntityHuman) this);
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 be29ecfa00d53ad2067015a5261184b4157c604b..4d0dcbcc00e44c4912302dd0e7331471f33cb370 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2902,6 +2902,15 @@ public class PlayerConnection implements PacketListenerPlayIn {
}
}
// Paper end
+ // Purpur start
+ if (worldserver.purpurConfig.signAllowColors) {
+ final org.bukkit.entity.Player bukkitPlayer = player.getBukkitEntity();
+ if (bukkitPlayer.hasPermission("purpur.sign.color")) currentLine = currentLine.replaceAll("(?i)&([0-9a-fr])", "\u00a7$1");
+ if (bukkitPlayer.hasPermission("purpur.sign.style")) currentLine = currentLine.replaceAll("(?i)&([l-or])", "\u00a7$1");
+ if (bukkitPlayer.hasPermission("purpur.sign.magic")) currentLine = currentLine.replaceAll("(?i)&([kr])", "\u00a7$1");
+ lines.add(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(currentLine));
+ } else
+ // Purpur end
lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterAllowedChatCharacters(currentLine))); // 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.at(worldserver, blockposition), this.getPlayer(), lines);
diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java
index 1e6bb566c0a718bba289b2e727a832e0aa6b7f15..b2afbf72ccf467d01449d75bc5123eb1816afd03 100644
--- a/src/main/java/net/minecraft/server/TileEntitySign.java
+++ b/src/main/java/net/minecraft/server/TileEntitySign.java
@@ -1,6 +1,7 @@
package net.minecraft.server;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
+import io.papermc.paper.adventure.PaperAdventure; // Purpur
import javax.annotation.Nullable;
public class TileEntitySign extends TileEntity implements ICommandListener { // CraftBukkit - implements
@@ -92,6 +93,18 @@ public class TileEntitySign extends TileEntity implements ICommandListener { //
this.g[i] = null;
}
+ // Purpur start
+ public PacketPlayOutTileEntityData getTranslatedUpdatePacket() {
+ NBTTagCompound nbt = save(new NBTTagCompound());
+ for (int i = 0; i < 4; ++i) {
+ String line = PaperAdventure.LEGACY_AMPERSAND.serialize(PaperAdventure.asAdventure(lines[i]));
+ nbt.setString("Text" + (i + 1), net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().serialize(net.kyori.adventure.text.Component.text(line)));
+ }
+ nbt.setString("PurpurEditor", "true");
+ 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 8393a0253ac16a8f15f78288d6cc31f8688c403c..484da2bf267cab4e4569c98111398af64c834eed 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -109,8 +109,10 @@ public class PurpurWorldConfig {
});
}
+ public boolean signAllowColors = false;
public boolean signRightClickEdit = false;
private void signSettings() {
+ signAllowColors = getBoolean("blocks.sign.allow-colors", signAllowColors);
signRightClickEdit = getBoolean("blocks.sign.right-click-edit", signRightClickEdit);
}