mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
PaperMC/Paper@4d6073f Partially fix #6880 (#6888) PaperMC/Paper@f8992ee Extend Entity by Sound.Emitter (#6890) PaperMC/Paper@db0bff9 Call onRemove logic for breakNaturally (#6854) PaperMC/Paper@72b731b Updated Upstream (CraftBukkit) (#6885) PaperMC/Paper@555f99d cleanup: Add hand to bucket events patch (#6881) PaperMC/Paper@51b7b60 Add API for resetting a single score (#6873) PaperMC/Paper@f3830bc Update paperweight to 1.2.0 (#6901) PaperMC/Paper@e22a1a9 Fix more namespacedkey parsing (#6903) PaperMC/Paper@284b3b8 Fix AnvilPrepareEvent not working with zero xp (#6895) PaperMC/Paper@22aaf91 Add config option to enable hopper occluding blocks (#6896)
87 lines
5.3 KiB
Diff
87 lines
5.3 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 7368e7df44c95aa5daa84e617d13ef140c3f96ed..dd8d1a7d634dd02050022ea178882b849c824c03 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -1462,6 +1462,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 68d51846987f4c5707cfc9dec737728770a66f11..367876813fcf772baf6542e1422b5c9572056a18 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -3102,11 +3102,16 @@ 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())));
|
|
- }
|
|
+ // Purpur start
|
|
+ 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 344d3a8c1162f1a4ab5fc2b7676680ddace46649..156a153abe59f86db7f942155d8a21de2fd83ce2 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
|
|
@@ -181,6 +181,22 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
|
return filtered ? this.filteredMessages : this.messages;
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ public ClientboundBlockEntityDataPacket getTranslatedUpdatePacket(boolean filtered) {
|
|
+ final CompoundTag nbt = save(new CompoundTag());
|
|
+ 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 new ClientboundBlockEntityDataPacket(worldPosition, 9, nbt);
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Nullable
|
|
@Override
|
|
public ClientboundBlockEntityDataPacket getUpdatePacket() {
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 5cfccc5a7ee50b24151d6886a1f336c6b217c24e..ea387b513f86249a6ceaa67cb6358dc56ed4b16d 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -153,8 +153,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);
|
|
}
|
|
|