Paper/Spigot-Server-Patches/0338-Fix-PlayerEditBookEvent.patch
Aikar 57dd397155
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
b999860d SPIGOT-2304: Add LootGenerateEvent

CraftBukkit Changes:
77fd87e4 SPIGOT-2304: Implement LootGenerateEvent
a1a705ee SPIGOT-5566: Doused campfires & fires should call EntityChangeBlockEvent
41712edd SPIGOT-5707: PersistentDataHolder not Persistent on API dropped Item
2020-05-01 18:03:57 -04:00

34 lines
1.8 KiB
Diff

From 9549441487fa359a7a6b323ab0aa73b8e7a62ce5 Mon Sep 17 00:00:00 2001
From: Michael Himing <mhiming@gmail.com>
Date: Sun, 16 Dec 2018 13:07:33 +1100
Subject: [PATCH] Fix PlayerEditBookEvent
- Updating book writing (not signing) mutated the original item, making
it impossible to properly cancel the event or modify the book meta
- When the event was cancelled, the client's book would keep the
cancelled writing
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 784f0a3f22..4b3ddfd990 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -871,9 +871,11 @@ public class PlayerConnection implements PacketListenerPlayIn {
itemstack2.a("pages", (NBTBase) nbttaglist);
this.player.a(packetplayinbedit.d(), CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, itemstack2)); // CraftBukkit
} else {
- ItemStack old = itemstack1.cloneItemStack(); // CraftBukkit
- itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8));
- CraftEventFactory.handleEditBookEvent(player, enumitemslot, old, itemstack1); // CraftBukkit
+ // Paper start - dont mutate players current item, set it from the event
+ ItemStack newBook = itemstack1.cloneItemStack();
+ newBook.getOrCreateTagAndSet("pages", (NBTBase)itemstack.getTag().getList("pages", 8));
+ this.player.setSlot(enumitemslot, CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, newBook));
+ // Paper end
}
}
--
2.26.2