mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@26734e8 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#7454) PaperMC/Paper@4a745f9 Optimize Util#sequence (#7115) PaperMC/Paper@2c8d48c Make Panda implement Sittable (#7414) PaperMC/Paper@2c4a589 Fix issues with LimitedRegion (#7343) PaperMC/Paper@3d91eca Fix cancelled snow bucket placement (#6751) PaperMC/Paper@9567753 Don't load plugins prefixed with a dot (#7392) PaperMC/Paper@92c777d Fix PlayerProfile BukkitObject serialization, deprecate setName and setId for removal (#7471) PaperMC/Paper@e6898ff Fix IllegalArgumentException for /paper mobcaps command (#7472) PaperMC/Paper@a8f2d67 - properly fix IllegalArgumentException in `/paper mobcaps` command Pufferfish Changes: pufferfish-gg/Pufferfish@22f20b2 Fix sentry bug
87 lines
5.4 KiB
Diff
87 lines
5.4 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/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index f300589fad36c5c9768474a13db74144b760c2a5..61b0b0a847042557d7b9cd20f0ad51f0ff1751b8 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -1496,6 +1496,7 @@ public class ServerPlayer extends Player {
|
|
|
|
@Override
|
|
public void openTextEdit(SignBlockEntity sign) {
|
|
+ if (level.purpurConfig.signAllowColors) this.connection.send(sign.getTranslatedUpdatePacket(textFilteringEnabled)); // Purpur
|
|
sign.setAllowedPlayerEditor(this.getUUID());
|
|
this.connection.send(new ClientboundBlockUpdatePacket(this.level, sign.getBlockPos()));
|
|
this.connection.send(new ClientboundOpenSignEditorPacket(sign.getBlockPos()));
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 84de797d405b55cd82d2c9068b924e7fd450e996..058c45ee30e687165d837980f7aed229475a4ea3 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -3163,11 +3163,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
}
|
|
// Paper end
|
|
|
|
- if (this.player.isTextFilteringEnabled()) {
|
|
- lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getFiltered())));
|
|
- } else {
|
|
- lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getRaw())));
|
|
- }
|
|
+ String line = SharedConstants.filterText(this.player.isTextFilteringEnabled() ? currentLine.getFiltered() : currentLine.getRaw());
|
|
+ if (worldserver.purpurConfig.signAllowColors) {
|
|
+ if (player.hasPermission("purpur.sign.color")) line = line.replaceAll("(?i)&([0-9a-fr])", "\u00a7$1");
|
|
+ if (player.hasPermission("purpur.sign.style")) line = line.replaceAll("(?i)&([l-or])", "\u00a7$1");
|
|
+ if (player.hasPermission("purpur.sign.magic")) line = line.replaceAll("(?i)&([kr])", "\u00a7$1");
|
|
+ lines.add(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(line));
|
|
+ } else
|
|
+ lines.add(net.kyori.adventure.text.Component.text(line));
|
|
+ // Purpur end
|
|
}
|
|
SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines);
|
|
this.cserver.getPluginManager().callEvent(event);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
|
index 6371176fba41218a209ea59b4cafe5b2d4a685fd..7666bca74f4f68bb4e902ec2eb7c4895adbb9373 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
|
@@ -184,6 +184,23 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
|
return ClientboundBlockEntityDataPacket.create(this);
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ public ClientboundBlockEntityDataPacket getTranslatedUpdatePacket(boolean filtered) {
|
|
+ final CompoundTag nbt = new CompoundTag();
|
|
+ this.saveAdditional(nbt);
|
|
+ final Component[] lines = getMessages(filtered);
|
|
+ for (int i = 0; i < 4; i++) {
|
|
+ final var component = io.papermc.paper.adventure.PaperAdventure.asAdventure(lines[i]);
|
|
+ final String line = io.papermc.paper.adventure.PaperAdventure.LEGACY_AMPERSAND.serialize(component);
|
|
+ final var text = net.kyori.adventure.text.Component.text(line);
|
|
+ final String json = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().serialize(text);
|
|
+ nbt.putString("Text" + (i + 1), json);
|
|
+ }
|
|
+ nbt.putString("PurpurEditor", "true");
|
|
+ return ClientboundBlockEntityDataPacket.create(this, entity -> nbt);
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Override
|
|
public CompoundTag getUpdateTag() {
|
|
return this.saveWithoutMetadata();
|
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
index 7b76d4f6ad4425b38f018f5dd1632b4801804013..f701ef5e6e58ce89d94fd0e5f2ae26721b0bd66b 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -924,8 +924,10 @@ public class PurpurWorldConfig {
|
|
}
|
|
|
|
public boolean signRightClickEdit = false;
|
|
+ public boolean signAllowColors = false;
|
|
private void signSettings() {
|
|
signRightClickEdit = getBoolean("blocks.sign.right-click-edit", signRightClickEdit);
|
|
+ signAllowColors = getBoolean("blocks.sign.allow-colors", signAllowColors);
|
|
}
|
|
|
|
public boolean slabHalfBreak = false;
|