[SPIGOT-6217] PlayerEditBookEvent is never called for edits Created: 03/Nov/20  Updated: 04/Nov/20  Resolved: 04/Nov/20

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Mariell Hoversholm Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None

Version: CraftBukkit commit 6fd677caf2dfa6212b11122e9b41b584e1ef314c
Guidelines Read: Yes

 Description   

I noticed this while updating (insert fork name) to 1.16.4.

In `PlayerConnection#a(String s, List<String> list, int i)`, the event is called as one expects. This method's name could be `bookSigningCallback`.

In `PlayerConnection#a(List<String> list, int i)`, the event is never called at all. This method's name could be `bookEditCallback`.

My solution to this issue was the following, though you may come up with something more future proof:

if (itemstack.getItem() == Items.WRITABLE_BOOK) {
  NBTTagList nbttaglist = new NBTTagList();

  list.stream().map(NBTTagString::a).forEach(nbttaglist::add);
  // Edits start - call PlayerEditBookEvent for non-signing
  ItemStack cloned = itemstack.cloneItemStack();
  cloned.getOrCreateTagAndSet("pages", (NBTBase) nbttaglist); // ItemStack#a(String, NBTBase)
  this.player.inventory.setItem(i, CraftEventFactory.handleEditBookEvent(player, i, itemstack, 
cloned));
  this.player.updateInventory(this.player.activeContainer);
  // Edits end
}

I apologise for not wanting to go through with the effort of compiling Spigot for this when the issue is that the behaviour doesn't exist in the code.


Generated at Sat Dec 13 17:11:47 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.