Files
Purpur/patches/server/0103-ALlow-color-codes-in-books.patch
William Blake Galbreath 8bc19e524a Updated Upstream (Paper & Tuinity)
Upstream has released updates that appears to apply and compile correctly

Paper Changes:
55e2de5c6 Improve per player mob spawning (#3971)
42433c262 Updated Upstream (Bukkit/CraftBukkit) (#3980)
e5ede546a Fix IDE Debug JVM Flag for 1.16 (#3983)
2712c6888 [Auto] Updated Upstream (Bukkit/CraftBukkit)
0901ffd04 Use title packet for actionbar methods (#3959)
2e11235d1 Expand MaterialTags (#3964)
cc25ae47c Amend last commit to fix decompile error forgot to commit
f503db37c Fix AdvancementDataPlayer leak due from quitting early in login
282763b88 Fix SPIGOT-5885 Unable to disable advancements
9b93d122e Fix SPIGOT-5824 Bukkit world-container is not used
bede4d304 Load config files early on

Tuinity Changes:
b0673b3 Merge dev/optimise-notify into ver/1.16
d3dc35c Name craft scheduler threads according to the plugin using them
2020-07-23 15:37:18 -05:00

60 lines
3.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Fri, 10 Jul 2020 09:40:30 -0500
Subject: [PATCH] ALlow color codes in books
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index c518d4346..194256e51 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -940,12 +940,13 @@ public class PlayerConnection implements PacketListenerPlayIn {
itemstack2.setTag(nbttagcompound.clone());
}
+ boolean hasPerm = getPlayer().hasPermission("purpur.book.color.edit") || getPlayer().hasPermission("purpur.book.color.sign");
itemstack2.a("author", (NBTBase) NBTTagString.a(this.player.getDisplayName().getString()));
- itemstack2.a("title", (NBTBase) NBTTagString.a(itemstack.getTag().getString("title")));
+ itemstack2.a("title", (NBTBase) NBTTagString.a(color(itemstack.getTag().getString("title"), hasPerm))); // Purpur - sign book
NBTTagList nbttaglist = itemstack.getTag().getList("pages", 8);
for (int i = 0; i < nbttaglist.size(); ++i) {
- String s = nbttaglist.getString(i);
+ String s = color(nbttaglist.getString(i), hasPerm);// Purpur - sign book
ChatComponentText chatcomponenttext = new ChatComponentText(s);
s = IChatBaseComponent.ChatSerializer.a((IChatBaseComponent) chatcomponenttext);
@@ -957,7 +958,14 @@ public class PlayerConnection implements PacketListenerPlayIn {
} else {
// Paper start - dont mutate players current item, set it from the event
ItemStack newBook = itemstack1.cloneItemStack();
- newBook.getOrCreateTagAndSet("pages", (NBTBase)itemstack.getTag().getList("pages", 8));
+ // Purpur start - edit book
+ boolean hasPerm = getPlayer().hasPermission("purpur.book.color.edit");
+ NBTTagList nbttaglist = itemstack.getTag().getList("pages", 8);
+ for (int i = 0; i < nbttaglist.size(); ++i) {
+ nbttaglist.set(i, NBTTagString.create(color(nbttaglist.getString(i), hasPerm, false)));
+ }
+ newBook.getOrCreateTagAndSet("pages", nbttaglist);
+ // Purpur end - edit book
this.player.setSlot(enumitemslot, CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, newBook));
// Paper end
}
@@ -967,6 +975,16 @@ public class PlayerConnection implements PacketListenerPlayIn {
}
}
+ // 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 a(PacketPlayInEntityNBTQuery packetplayinentitynbtquery) {
PlayerConnectionUtils.ensureMainThread(packetplayinentitynbtquery, this, this.player.getWorldServer());