mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 17:07:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 2c6b1f048 Revert "Remove itneract event from boat" (Fixes #5677) aae1c54a9 Add command line option to load extra plugin jars not in the plugins folder 322886c86 Avoid NPE due to PlayerBedFailEnterEvent d3c9a195c removed duplicate ProjectileHitEvent for fireball (#5671) 7989028a5 More Enchantment API (#5588) c0cb5c129 Adds methods for checking item repairability (#5651) 22399b07f Actually use extended/ambient in BeaconEffectEvent (#5647) 979135878 Add cause and cancel message to PlayerGameModeChangeEvent (#5638) 51e1e58d2 Fix Adventure support in UnknownCommandEvent (#5664) 45e19ffb0 [Auto] Updated Upstream (CraftBukkit) 151457628 Fix Counter#decrement recursive call (#5665) 21ac7dc98 [Auto] Updated Upstream (CraftBukkit) 18ad2c9dd Add environment variable (PAPER_DISABLE_SERVER_GUI) to disable server gui
55 lines
3.1 KiB
Diff
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 a48a1e13adfc70ac0887b3a4c3c7f3a1d92a9606..7a68762abd3334d6a5f43b680e5d18ace863ab95 100644
|
|
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
@@ -1216,7 +1216,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)
|
|
@@ -1234,13 +1235,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);
|
|
|
|
@@ -1252,6 +1254,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());
|