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

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2021-04-07 15:03:29 +10:00
parent 97cd7810a3
commit 834f035a21

View File

@ -1273,7 +1273,7 @@ public class CraftEventFactory {
}
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);
// If they've got the same item in their hand, it'll need to be updated.