mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: fb36f15d6 Let some more packets be send immediately, closes #4140 (#4896) ede41fe16 Emancipate more features to PlayerHandshakeEvent 3fdeba1f5 [CI-SKIP] [Auto] Rebuild Patches 5fc07bd63 Maded Title-Objects directy sendable to targets e7b9a478e Player Chunk Load/Unload Events 1d0cfc0cc MC-4 Fix item position desync 458db6206 Limit auto recipe packets
55 lines
2.9 KiB
Diff
55 lines
2.9 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/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
index e2cbffd113c3b49522786df62b4285fe6763434e..7dab659663f0b9e115e3eee98ef71c072f52f061 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -1008,7 +1008,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);
|
|
CraftEventFactory.handleEditBookEvent(player, i, old, itemstack); // CraftBukkit
|
|
@@ -1026,13 +1027,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);
|
|
|
|
@@ -1044,6 +1046,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());
|