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@5e73c55 [ci skip] Add more identifying patch comments PaperMC/Paper@3e20d3a [ci skip] Add more identifying patch comments PaperMC/Paper@f61ebdc Fix issue with kick event causes being passed improperly PaperMC/Paper@106c67a [ci skip] Add more identifying patch comments PaperMC/Paper@cc693ce [ci skip] Add more identifying patch comments, merge related patches PaperMC/Paper@eeb6afc [ci skip] Add more identifying patch comments, merge related patches PaperMC/Paper@1c956ab [ci skip] Add more identifying patch comments, merge related patches PaperMC/Paper@42e88a8 [ci skip] Add more identifying patch comments PaperMC/Paper@8e41ef4 Add visual blockdata api for primed tnt (#10146) PaperMC/Paper@68c3297 [ci skip] Add more identifying patch comments PaperMC/Paper@4a98986 Add back Reduce allocation of Vec3D by entity tracker patch (#10179) PaperMC/Paper@b48d737 Async world data IO saving (#10171) PaperMC/Paper@8d94596 [ci skip] Add more identifying patch comments PaperMC/Paper@f7dd304 [ci skip] Add more identifying patch comments PaperMC/Paper@98e6d20 [ci skip] Add more identifying patch comments PaperMC/Paper@e9e0bc1 [ci skip] Add more identifying patch comments PaperMC/Paper@d9df6bc [ci skip] Add more patch identifying comments, cleanup PaperMC/Paper@27cabc1 [ci skip] Add more patch identifying comments Pufferfish Changes: pufferfish-gg/Pufferfish@8e208d3 Fix Async World Saving attribution
78 lines
4.6 KiB
Diff
78 lines
4.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Tue, 3 Nov 2020 01:25:06 -0600
|
|
Subject: [PATCH] Allow color codes in books
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 7c829f26b29bb3e02248bfd8d63b600c232ebd3e..063a1a979755d63bd3d099f07348c7a587adbe3d 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -1231,13 +1231,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
itemstack1.setTag(nbttagcompound.copy());
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ boolean hasPerm = getCraftPlayer().hasPermission("purpur.book.color.edit") || getCraftPlayer().hasPermission("purpur.book.color.sign");
|
|
itemstack1.addTagElement("author", StringTag.valueOf(this.player.getName().getString()));
|
|
if (this.player.isTextFilteringEnabled()) {
|
|
- itemstack1.addTagElement("title", StringTag.valueOf(title.filteredOrEmpty()));
|
|
+ itemstack1.addTagElement("title", StringTag.valueOf(color(title.filteredOrEmpty(), hasPerm)));
|
|
} else {
|
|
- itemstack1.addTagElement("filtered_title", StringTag.valueOf(title.filteredOrEmpty()));
|
|
- itemstack1.addTagElement("title", StringTag.valueOf(title.raw()));
|
|
+ itemstack1.addTagElement("filtered_title", StringTag.valueOf(color(title.filteredOrEmpty(), hasPerm)));
|
|
+ itemstack1.addTagElement("title", StringTag.valueOf(color(title.raw(), hasPerm)));
|
|
}
|
|
+ // Purpur end
|
|
|
|
this.updateBookPages(pages, (s) -> {
|
|
return Component.Serializer.toJson(Component.literal(s));
|
|
@@ -1249,10 +1252,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
private void updateBookPages(List<FilteredText> list, UnaryOperator<String> unaryoperator, ItemStack itemstack, int slot, ItemStack handItem) { // CraftBukkit
|
|
ListTag nbttaglist = new ListTag();
|
|
|
|
+ // Purpur start
|
|
+ boolean hasPerm = getCraftPlayer().hasPermission("purpur.book.color.edit");
|
|
if (this.player.isTextFilteringEnabled()) {
|
|
- Stream<StringTag> stream = list.stream().map((filteredtext) -> { // CraftBukkit - decompile error
|
|
- return StringTag.valueOf((String) unaryoperator.apply(filteredtext.filteredOrEmpty()));
|
|
+ Stream<StringTag> stream = list.stream().map(s -> color(s.filteredOrEmpty(), hasPerm, false)).map((s) -> { // CraftBukkit - decompile error
|
|
+ return StringTag.valueOf((String) unaryoperator.apply(s));
|
|
});
|
|
+ // Purpur end
|
|
|
|
Objects.requireNonNull(nbttaglist);
|
|
stream.forEach(nbttaglist::add);
|
|
@@ -1262,11 +1268,11 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
|
|
for (int j = list.size(); i < j; ++i) {
|
|
FilteredText filteredtext = (FilteredText) list.get(i);
|
|
- String s = filteredtext.raw();
|
|
+ String s = color(filteredtext.raw(), hasPerm, false); // Purpur
|
|
|
|
nbttaglist.add(StringTag.valueOf((String) unaryoperator.apply(s)));
|
|
if (filteredtext.isFiltered()) {
|
|
- nbttagcompound.putString(String.valueOf(i), (String) unaryoperator.apply(filteredtext.filteredOrEmpty()));
|
|
+ nbttagcompound.putString(String.valueOf(i), (String) unaryoperator.apply((String) color(filteredtext.filteredOrEmpty(), hasPerm, false))); // Purpur
|
|
}
|
|
}
|
|
|
|
@@ -1279,6 +1285,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
this.player.getInventory().setItem(slot, CraftEventFactory.handleEditBookEvent(this.player, slot, handItem, itemstack)); // CraftBukkit // Paper - Don't ignore result (see other callsite for handleEditBookEvent)
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ private String color(String str, boolean hasPerm) {
|
|
+ return color(str, hasPerm, true);
|
|
+ }
|
|
+
|
|
+ private String color(String str, boolean hasPerm, boolean parseHex) {
|
|
+ return hasPerm ? org.bukkit.ChatColor.color(str, parseHex) : str;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Override
|
|
public void handleEntityTagQuery(ServerboundEntityTagQuery packet) {
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|