mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 00:47:42 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: eb11845f8 Fix creating worlds with "invalid" names (Fixes #5331) e4d8a6279 Implement Keyed on World bcb63dab7 [CI-SKIP] [Auto] Rebuild Patches 48342b06c Allow signs that are inside of the spawn protection to be right clicked to use their run_command tag c229f90c1 Add Block#isValidTool 20e709c1d Add recipe to cook events 2dcf8bff4 legacy formatting will be the death of me f597fea0d legacy formatting is worse than walking around in wet socks 7f72c4675 Use implementation-provided legacy serializer for events 27a8d99ec Adventure 4.7.0 e65bd35a1 Respect teams in legacy chat name if configured (#5321) b31089a92 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5325) a52b30814 Fix title swapping fadeIn and stay 54ec85949 Prevent grindstones from overstacking items d7795080c Fix NPE for AIR in meta operations in ItemStack 2e70796c7 [CI-SKIP] Improve documentation of PreCreatureSpawnEvent (#5244) 7bb92e750 [CI-SKIP] Add JavaDoc links to Tag class pointing to custom Paper tags (#5285) 28cd686bf fix per-world difficulty command (#5306) be7cde2c7 [CI-SKIP] Always check PATH for JDK (#5315)
85 lines
4.9 KiB
Diff
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 599d7fbc4db928a9825e154c09c9a74d39a39a03..8bfff671ed779991b8ef5433cfec61b405a184ba 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);
|
|
}
|
|
|