mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 0514fc4e2 Add missing effects 8f5d9effd Add getMainThreadExecutor to BukkitScheduler 313b5020b Allow adding items to BlockDropItemEvent (#5093) 9a556d9da [CI-SKIP] [Auto] Rebuild Patches 72b2768ad Inline shift fields in EnumDirection (#5082) ffff53fa7 added option to disable pathfinding updates on block changes (#5123) b67081fd7 add DragonEggFormEvent (fixes #5110) (#5112) 3eefafbaf Fix javadoc build 0081ed1c4 Add javadoc step to GH Actions 01082503e Add dropLeash variable to EntityUnleashEvent (#5130) 31f9f869a [CI-SKIP] Fix YourKit links in readme, fixes #5091 8ac27aa38 [Auto] Updated Upstream (CraftBukkit) c4d9cc831 [Auto] Updated Upstream (Bukkit/CraftBukkit) d0477d326 [Auto] Updated Upstream (CraftBukkit) d9f5f7018 EntityMoveEvent (#4614)
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 3fca11948fad36b6adec55883d365e58a17925fa..ffccdc3bf1d28836f4fc2772ebfde843415ea232 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -1029,7 +1029,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
|
|
@@ -1047,13 +1048,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);
|
|
|
|
@@ -1065,6 +1067,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());
|