PaperMC/Spigot-Server-Patches/0412-Fix-PlayerEditBookEvent.patch
Zach Brown 1e38743b1d
Update upstream B/CB/S
Also fixes build as a result of an upstream force push

--- work/Bukkit
Submodule work/Bukkit 217dc08d..d13fdf8c:
  > SPIGOT-4637: Add source block to BlockPhysicsEvent.

--- work/CraftBukkit
Submodule work/CraftBukkit acbba8ba..cb98c6ea:
  > Fix line endings in CraftDefaultPermissions
  > SPIGOT-4637: Add source block to BlockPhysicsEvent.

--- work/Spigot
Submodule work/Spigot 75ee78a0c...4165cd8f4 (commits not present)
  > (Manually Added) - Appears to be a result of an upstream force push
  > (Manually Added) - Changed: SPIGOT-4636: Add creative mode NBT permissions
2019-02-25 04:39:24 -05:00

35 lines
2 KiB
Diff

From a72c697a8c700ec3a3b540245003d12540516a6f 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 391ecc9db..04344a371 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -823,10 +823,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
this.player.setSlot(enumitemslot, 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
}
+ player.getBukkitEntity().updateInventory(); // Paper - fix client desync when event is cancelled
}
}
--
2.20.1