mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 08:57:44 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 5b20df6bf added PlayerNameEntityEvent ff9c82444 Add worldborder events 616b1f3cd consider enchants for destroy speed aaef1d5cc fix file conversion 674d8f7f7 Make discovered maps config work in treasure maps from loot tables too be1687914 stop firing pressure plate EntityInteractEvent for ignored entities (fixes #4962) 7d56f38ed Do not use the bukkit singleton for the GUI (Fixes #5301) 4c9bdf53a Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5299) 8647bd130 Improve ServerGUI fcc6d3359 Throw proper exception on empty JsonList file 17d2e1291 Fix interact event in adventure mode 964e0bf42 MC-29274: Fix Wither hostility towards players 9e24a5213 Fixed furnace cook-speed multiplier losing precision when calculating cook time c7e42faa3 Do not create unnecessary copies of the passenger list 40881ad67 added tnt minecarts to the tnt height nerf 26be708f4 Remove streams from SensorNearest 5b5989b21 fix nullability of playerlist header/footer, closes #5290 45bc531dd Fix Material#getTranslationKey for Block Materials (#5294)
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 1faaf6b7d3c45ad9445b0d6b3842a5ee24dc8275..367f1d93c81a688d93d874c6909bb61c60e99606 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -1058,7 +1058,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
|
|
@@ -1076,13 +1077,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);
|
|
|
|
@@ -1094,6 +1096,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());
|