Package io.papermc.paper.event.player
Class PlayerInsertLecternBookEvent
java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
io.papermc.paper.event.player.PlayerInsertLecternBookEvent
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result
-
Field Summary
Fields inherited from class org.bukkit.event.player.PlayerEvent
player
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetBlock()
Gets the block of the lectern involved in this event.getBook()
Returns the itemstack the player tried to insert.static HandlerList
Fetches the lectern block state that was part of this event.boolean
Gets the cancellation state of this event.void
Sets the itemstack to insert into the lectern.void
setCancelled
(boolean cancel) Sets the cancellation state of this event.Methods inherited from class org.bukkit.event.player.PlayerEvent
getPlayer
Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
PlayerInsertLecternBookEvent
-
-
Method Details
-
getBlock
Gets the block of the lectern involved in this event.- Returns:
- the block of the lectern
-
getLectern
Fetches the lectern block state that was part of this event. This method constructs a new snapshotBlockState
.- Returns:
- a new lectern state snapshot of the involved lectern
- Throws:
IllegalStateException
- if the block atgetBlock()
is no longer a lectern
-
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, usesetBook(ItemStack)
.- Returns:
- the book that is being placed
-
setBook
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 interfaceCancellable
- 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 interfaceCancellable
- Parameters:
cancel
- true if you wish to cancel this event
-
getHandlers
- Specified by:
getHandlers
in classEvent
-
getHandlerList
-