on interactorg.bukkit.event.player.PlayerInteractEventPlayer1.0.0
Description
Fires when a player interacts with a block or air.
Variables
playerPlayer
NullableNo
The player who interacted
actionString
NullableNo
The action type: LEFT_CLICK_BLOCK, RIGHT_CLICK_BLOCK, LEFT_CLICK_AIR, RIGHT_CLICK_AIR, or PHYSICAL (triggering a block by stepping on or colliding with it, such as pressure plates or farmland).
blockBlock
NullableYes
The block involved in the interaction, or null if the action targets air
itemItemStack
NullableYes
The item in the player's hand, or null if empty
Examples
on interact:on interact:
if action is "LEFT_CLICK_BLOCK":
message player "You left clicked a block!"on interact:
if action is "RIGHT_CLICK_BLOCK":
message player "You right clicked a block!"
else if action is "LEFT_CLICK_AIR":
message player "You left clicked in the air!"