Files
Purpur/patches/server/0085-Allow-color-codes-in-books.patch
BillyGalbreath 7f7f024f02 Updated Upstream (Paper, Tuinity, & Airplane)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
8a29f5894 [Auto] Updated Upstream (Bukkit/CraftBukkit)
8756d232c Expose server protocol version (#5416)
4492bc4cc remove l4j class no longer in existence from preload list
be1370517 Updated Upstream (CraftBukkit) (#5484)
d560151ec Bump mysql-connector-java to 8.0.23 (Fixes #5473) (#5474)
61f400f11 Update log4j to 2.11.2 for JDK 9+ compat (#5400)
a98196585 Updated Upstream (Bukkit/CraftBukkit)
de138fac4 [Auto] Updated Upstream (Bukkit)
304a216ba [CI-SKIP] Ignore gitignore when adding files in automation
d8e384a16 [CI-SKIP] Drop `Allow PlayerEditBookEvent to fire for off hand` (#5471)

Tuinity Changes:
d5261ad29 Do not load chunks for getCubes by default
da9cf9828 Don't read neighbor chunk data off disk when converting chunks
a0aa5ab07 Do not load 1 radius neighbors for lighting
5ccfa52a2 Fix terrible patch times
af53d703a Stop large move vectors in player packet handling from killing the server
6e56ee735 Fix OBFHELPER for flushHeaderin RegionFile
995d05c1c Do not update TE's in generating chunks

Airplane Changes:
8de8e82a2 Update upstream (Tuinity)
2021-04-13 10:56:32 -05:00

55 lines
3.1 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/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
index f45bbf7a4ab4d841a12270c1399fb09538b9fe90..38273c73610b23ba75db658763cbb2e4c4871d58 100644
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
@@ -1209,7 +1209,8 @@ public class PlayerConnection implements PacketListenerPlayIn {
if (itemstack.getItem() == Items.WRITABLE_BOOK) {
NBTTagList nbttaglist = new NBTTagList();
- list.stream().map(NBTTagString::a).forEach(nbttaglist::add);
+ boolean hasPerm = getPlayer().hasPermission("purpur.book.color.edit"); // Purpur - edit book
+ list.stream().map(s -> s = color(s, hasPerm, false)).map(NBTTagString::a).forEach(nbttaglist::add); // Purpur - edit book
ItemStack old = itemstack.cloneItemStack(); // CraftBukkit
itemstack.a("pages", (NBTBase) nbttaglist);
this.player.inventory.setItem(i, CraftEventFactory.handleEditBookEvent(player, i, old, itemstack)); // CraftBukkit // Paper - Don't ignore result (see other callsite for handleEditBookEvent)
@@ -1227,13 +1228,14 @@ public class PlayerConnection implements PacketListenerPlayIn {
itemstack1.setTag(nbttagcompound.clone());
}
+ boolean hasPerm = getPlayer().hasPermission("purpur.book.color.edit") || getPlayer().hasPermission("purpur.book.color.sign"); // Purpur
itemstack1.a("author", (NBTBase) NBTTagString.a(this.player.getDisplayName().getString()));
- itemstack1.a("title", (NBTBase) NBTTagString.a(s));
+ itemstack1.a("title", (NBTBase) NBTTagString.a(color(s, hasPerm))); // Purpur - sign book
NBTTagList nbttaglist = new NBTTagList();
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
- String s1 = (String) iterator.next();
+ String s1 = color((String) iterator.next(), hasPerm);// Purpur - sign book
ChatComponentText chatcomponenttext = new ChatComponentText(s1);
String s2 = IChatBaseComponent.ChatSerializer.a((IChatBaseComponent) chatcomponenttext);
@@ -1245,6 +1247,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());