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: dc7b7a160 Fix missing username console death message (#5654) (#5658) c639a52a6 Add basic Datapack API (#5653) (#5653) 99c1d9da6 Updated Upstream (CraftBukkit) (#5652) 2d50c17e2 [CI-SKIP] Add PR rebasing steps (#5634) 2c5f8085e Remove boat interaction event (Fixes #5539) 96ee1fb8f fix WorldSaveEvent not firing with /save-all (#5650) e90e7829e remove unneeded patch (#5641) d875bacc2 Activate warning by default when people are doing silly things (#5642) cb896d471 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5643) ecbf5a38e Revert "Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5636)" 20fc4ab70 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5636) 20d8812ea Fix CraftPotionBrewer cache (#5632) Tuinity Changes: 1222573d0 Fix incorrect status dataconverter for pre 1.13 chunks
85 lines
5.0 KiB
Diff
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 b336e47b21a0693ebfeae8eb752258a3e2f6d4f4..7128e72f6496768293d305bdecb1f1f3cd2220b0 100644
|
|
--- a/src/main/java/net/minecraft/server/level/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/EntityPlayer.java
|
|
@@ -1594,6 +1594,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 a0a476d55afdf5ed9850368e99ab25af019075a8..3559f52e2fa30a8a7600334ece981fe34896bd68 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);
|
|
}
|
|
|