Package io.papermc.paper.event.block
Class BlockLockCheckEvent
java.lang.Object
org.bukkit.event.Event
org.bukkit.event.block.BlockEvent
io.papermc.paper.event.block.BlockLockCheckEvent
Called when the server tries to check the lock on a lockable block entity.
See
See
setResult(Result) to change behavior-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result -
Field Summary
Fields inherited from class org.bukkit.event.block.BlockEvent
block -
Constructor Summary
ConstructorsConstructorDescriptionBlockLockCheckEvent(Block block, Player player, Component lockedMessage, Sound lockedSound) -
Method Summary
Modifier and TypeMethodDescriptionvoiddenyWithMessageAndSound(@Nullable Component lockedMessage, @Nullable Sound lockedSound) Shorthand method to set thegetResult()toEvent.Result.DENY, the locked message and locked sound.Gets the snapshotLockableTileStateof the block entity whose lock is being checked.static HandlerListGets the itemstack that will be used as the key itemstack.Gets the locked message that will be sent if the player cannot open the block.Gets the locked sound that will play if the player cannot open the block.Get the player involved this lock check.Gets the result of this event.booleanChecks if a custom key stack has been set.voidReset the key stack to the default (the player's main hand).voidsetKeyItem(ItemStack stack) Sets the itemstack that will be used as the key item.voidsetLockedMessage(@Nullable Component lockedMessage) Sets the locked message that will be sent if the player cannot open the block.voidsetLockedSound(@Nullable Sound lockedSound) Sets the locked sound that will play if the player cannot open the block.voidsetResult(Event.Result result) Gets the result of this event.Methods inherited from class org.bukkit.event.block.BlockEvent
getBlockMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
BlockLockCheckEvent
-
-
Method Details
-
getBlockState
Gets the snapshotLockableTileStateof the block entity whose lock is being checked.- Returns:
- the snapshot block state.
-
getPlayer
Get the player involved this lock check.- Returns:
- the player
-
getKeyItem
Gets the itemstack that will be used as the key itemstack. Initially this will be the item in the player's main hand but an override can be set withsetKeyItem(ItemStack). UseisUsingCustomKeyItemStack()to check if a custom key stack has been set.- Returns:
- the item being used as the key item
- See Also:
-
setKeyItem
Sets the itemstack that will be used as the key item.- Parameters:
stack- the stack to use as a key- See Also:
-
resetKeyItem
public void resetKeyItem()Reset the key stack to the default (the player's main hand). -
isUsingCustomKeyItemStack
public boolean isUsingCustomKeyItemStack()Checks if a custom key stack has been set.- Returns:
trueif a custom key itemstack has been set
-
getResult
Gets the result of this event.- Returns:
- the result
- See Also:
-
setResult
Gets the result of this event.Event.Result.DEFAULTis the default allowing the vanilla logic to check the lock of this block. Set toEvent.Result.ALLOWorEvent.Result.DENYto override that behavior.Setting this to
Event.Result.ALLOWbypasses the spectator check.- Parameters:
result- the result of this event
-
denyWithMessageAndSound
Shorthand method to set thegetResult()toEvent.Result.DENY, the locked message and locked sound.- Parameters:
lockedMessage- the message to show if locked (ornullfor none)lockedSound- the sound to play if locked (ornullfor none)
-
getLockedMessage
Gets the locked message that will be sent if the player cannot open the block.- Returns:
- the locked message (or
nullif none)
-
setLockedMessage
Sets the locked message that will be sent if the player cannot open the block.- Parameters:
lockedMessage- the locked message (ornullfor none)
-
getLockedSound
Gets the locked sound that will play if the player cannot open the block.- Returns:
- the locked sound (or
nullif none)
-
setLockedSound
Sets the locked sound that will play if the player cannot open the block.- Parameters:
lockedSound- the locked sound (ornullfor none)
-
getHandlers
- Specified by:
getHandlersin classEvent
-
getHandlerList
-