Class PlayerInsertLecternBookEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
io.papermc.paper.event.player.PlayerInsertLecternBookEvent
All Implemented Interfaces:
Cancellable

@NullMarked public class PlayerInsertLecternBookEvent extends PlayerEvent implements Cancellable
This event is called when a player clicks on a lectern to insert a book. If this event is cancelled the player will keep the book and the lectern will remain empty.
  • Constructor Details

  • Method Details

    • getBlock

      public Block getBlock()
      Gets the block of the lectern involved in this event.
      Returns:
      the block of the lectern
    • getLectern

      public Lectern getLectern()
      Fetches the lectern block state that was part of this event. This method constructs a new snapshot BlockState.
      Returns:
      a new lectern state snapshot of the involved lectern
      Throws:
      IllegalStateException - if the block at getBlock() is no longer a lectern
    • getBook

      public ItemStack getBook()
      Returns the itemstack the player tried to insert. This is a copy of the item, changes made to this itemstack will not affect the book that is being placed in the lectern. If you want to mutate the item stack that ends up in the lectern, use setBook(ItemStack).
      Returns:
      the book that is being placed
    • setBook

      public void setBook(ItemStack book)
      Sets the itemstack to insert into the lectern.
      Parameters:
      book - the book to insert (non book items will leave the lectern in a locked state as the menu cannot be opened, preventing item extraction)
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: Cancellable
      Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins
      Specified by:
      isCancelled in interface Cancellable
      Returns:
      true if this event is cancelled
    • setCancelled

      public void setCancelled(boolean cancel)
      Description copied from interface: Cancellable
      Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.
      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancel - true if you wish to cancel this event
    • getHandlers

      public HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList

      public static HandlerList getHandlerList()