SPIGOT-6411: The PlayerEditBookEvent is not called when the player edits a book in the off-hand.

This commit is contained in:
md_5 2021-04-07 15:03:29 +10:00
parent be0e945812
commit 721c4966be
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -1273,7 +1273,7 @@ public class CraftEventFactory {
} }
public static ItemStack handleEditBookEvent(EntityPlayer player, int itemInHandIndex, ItemStack itemInHand, ItemStack newBookItem) { public static ItemStack handleEditBookEvent(EntityPlayer player, int itemInHandIndex, ItemStack itemInHand, ItemStack newBookItem) {
PlayerEditBookEvent editBookEvent = new PlayerEditBookEvent(player.getBukkitEntity(), itemInHandIndex, (BookMeta) CraftItemStack.getItemMeta(itemInHand), (BookMeta) CraftItemStack.getItemMeta(newBookItem), newBookItem.getItem() == Items.WRITTEN_BOOK); PlayerEditBookEvent editBookEvent = new PlayerEditBookEvent(player.getBukkitEntity(), (itemInHandIndex >= 0 && itemInHandIndex <= 8) ? itemInHandIndex : -1, (BookMeta) CraftItemStack.getItemMeta(itemInHand), (BookMeta) CraftItemStack.getItemMeta(newBookItem), newBookItem.getItem() == Items.WRITTEN_BOOK);
player.world.getServer().getPluginManager().callEvent(editBookEvent); player.world.getServer().getPluginManager().callEvent(editBookEvent);
// If they've got the same item in their hand, it'll need to be updated. // If they've got the same item in their hand, it'll need to be updated.