Files
Purpur/patches/server/0046-Signs-allow-color-codes.patch
Ben Kerllenevich 6bd246b947 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
2c6b1f048 Revert "Remove itneract event from boat" (Fixes #5677)
aae1c54a9 Add command line option to load extra plugin jars not in the plugins folder
322886c86 Avoid NPE due to PlayerBedFailEnterEvent
d3c9a195c removed duplicate ProjectileHitEvent for fireball (#5671)
7989028a5 More Enchantment API (#5588)
c0cb5c129 Adds methods for checking item repairability (#5651)
22399b07f Actually use extended/ambient in BeaconEffectEvent (#5647)
979135878 Add cause and cancel message to PlayerGameModeChangeEvent (#5638)
51e1e58d2 Fix Adventure support in UnknownCommandEvent (#5664)
45e19ffb0 [Auto] Updated Upstream (CraftBukkit)
151457628 Fix Counter#decrement recursive call (#5665)
21ac7dc98 [Auto] Updated Upstream (CraftBukkit)
18ad2c9dd Add environment variable (PAPER_DISABLE_SERVER_GUI) to disable server gui
2021-05-19 18:01:23 -04:00

85 lines
5.0 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/level/EntityPlayer.java b/src/main/java/net/minecraft/server/level/EntityPlayer.java
index e65a3e3e7bf6a366c30b44e166e2085966ebc933..a8d60d288afd9b413494fe6abe8cfddb7c1f0b3b 100644
--- a/src/main/java/net/minecraft/server/level/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/level/EntityPlayer.java
@@ -1603,6 +1603,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/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
index 880521dfbf1513eee581c38c839f00b385b6fb33..a48a1e13adfc70ac0887b3a4c3c7f3a1d92a9606 100644
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
@@ -3078,6 +3078,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/world/level/block/entity/TileEntitySign.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntitySign.java
index 96d0524482281f8570464962c0fd5319199440d7..a87a2fa507dc3bd6d9979db5868e7ef6ea1eddbd 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntitySign.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntitySign.java
@@ -1,6 +1,7 @@
package net.minecraft.world.level.block.entity;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
+import io.papermc.paper.adventure.PaperAdventure; // Purpur
import javax.annotation.Nullable;
import net.minecraft.commands.CommandListenerWrapper;
import net.minecraft.commands.ICommandListener;
@@ -112,6 +113,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 ea95a4116371d58eb36be51093af7f0fa28e3dfd..b67f87f38d0ff99ff62d2103ecc737317a435102 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);
}