From ae4e86af2d2d3577a40b500cd412c31442df82b4 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sun, 6 Jan 2019 17:48:24 +0000 Subject: [PATCH] Use OBFHELPER in previous commit --- Spigot-Server-Patches/Fix-PlayerEditBookEvent.patch | 4 ++-- Spigot-Server-Patches/MC-Utils.patch | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Spigot-Server-Patches/Fix-PlayerEditBookEvent.patch b/Spigot-Server-Patches/Fix-PlayerEditBookEvent.patch index b2b498629f..804d9e0819 100644 --- a/Spigot-Server-Patches/Fix-PlayerEditBookEvent.patch +++ b/Spigot-Server-Patches/Fix-PlayerEditBookEvent.patch @@ -10,7 +10,7 @@ it impossible to properly cancel the event or modify the book meta cancelled writing diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 74c570615..616dbb152 100644 +index 74c570615..9741d3b23 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { @@ -22,7 +22,7 @@ index 74c570615..616dbb152 100644 - CraftEventFactory.handleEditBookEvent(player, enumitemslot, old, itemstack1); // CraftBukkit + // Paper start - dont mutate players current item, set it from the event + ItemStack newBook = itemstack1.cloneItemStack(); -+ newBook.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8)); ++ newBook.getOrCreateTagAndSet("pages", (NBTBase) itemstack.getTag().getList("pages", 8)); + this.player.setSlot(enumitemslot, CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, newBook)); + // Paper end } diff --git a/Spigot-Server-Patches/MC-Utils.patch b/Spigot-Server-Patches/MC-Utils.patch index bcdcda843a..c18c800f5f 100644 --- a/Spigot-Server-Patches/MC-Utils.patch +++ b/Spigot-Server-Patches/MC-Utils.patch @@ -297,7 +297,7 @@ index b8abd6363..a07ee150c 100644 // Paper end } diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java -index 53511f0cc..00e230037 100644 +index 53511f0cc..d1267f3d7 100644 --- a/src/main/java/net/minecraft/server/ItemStack.java +++ b/src/main/java/net/minecraft/server/ItemStack.java @@ -0,0 +0,0 @@ public final class ItemStack { @@ -318,6 +318,14 @@ index 53511f0cc..00e230037 100644 public void setTag(@Nullable NBTTagCompound nbttagcompound) { this.tag = nbttagcompound; } +@@ -0,0 +0,0 @@ public final class ItemStack { + return this.tag != null && this.tag.hasKeyOfType("Enchantments", 9) ? !this.tag.getList("Enchantments", 10).isEmpty() : false; + } + ++ public void getOrCreateTagAndSet(String s, NBTBase nbtbase) { a(s, nbtbase);} // Paper - OBFHELPER + public void a(String s, NBTBase nbtbase) { + this.getOrCreateTag().set(s, nbtbase); + } diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java new file mode 100644 index 000000000..c97e116aa