public class PlayerInteractEvent extends PlayerEvent implements Cancellable
This event will fire as cancelled if the vanilla behavior is to do nothing (e.g interacting with air)
Event.Result
Modifier and Type | Field and Description |
---|---|
protected Action |
action |
protected Block |
blockClicked |
protected BlockFace |
blockFace |
protected ItemStack |
item |
player
Constructor and Description |
---|
PlayerInteractEvent(Player who,
Action action,
ItemStack item,
Block clickedBlock,
BlockFace clickedFace) |
Modifier and Type | Method and Description |
---|---|
Action |
getAction()
Returns the action type
|
BlockFace |
getBlockFace()
Returns the face of the block that was clicked
|
Block |
getClickedBlock()
Returns the clicked block
|
static HandlerList |
getHandlerList() |
HandlerList |
getHandlers() |
ItemStack |
getItem()
Returns the item in hand represented by this event
|
Material |
getMaterial()
Convenience method.
|
boolean |
hasBlock()
Check if this event involved a block
|
boolean |
hasItem()
Check if this event involved an item
|
boolean |
isBlockInHand()
Convenience method to inform the user whether this was a block
placement event.
|
boolean |
isCancelled()
Gets the cancellation state of this event.
|
void |
setCancelled(boolean cancel)
Sets the cancellation state of this event.
|
void |
setUseInteractedBlock(Event.Result useInteractedBlock) |
void |
setUseItemInHand(Event.Result useItemInHand) |
Event.Result |
useInteractedBlock()
This controls the action to take with the block (if any) that was
clicked on.
|
Event.Result |
useItemInHand()
This controls the action to take with the item the player is holding.
|
getPlayer
getEventName, isAsynchronous
protected ItemStack item
protected Action action
protected Block blockClicked
protected BlockFace blockFace
public Action getAction()
public boolean isCancelled()
isCancelled
in interface Cancellable
public void setCancelled(boolean cancel)
Canceling this event will prevent use of food (player won't lose the food item), prevent bows/snowballs/eggs from firing, etc. (player won't lose the ammo)
setCancelled
in interface Cancellable
cancel
- true if you wish to cancel this eventpublic ItemStack getItem()
public Material getMaterial()
public boolean hasBlock()
public boolean hasItem()
public boolean isBlockInHand()
public Block getClickedBlock()
public BlockFace getBlockFace()
public Event.Result useInteractedBlock()
public void setUseInteractedBlock(Event.Result useInteractedBlock)
useInteractedBlock
- the action to take with the interacted blockpublic Event.Result useItemInHand()
public void setUseItemInHand(Event.Result useItemInHand)
useItemInHand
- the action to take with the item in handpublic HandlerList getHandlers()
getHandlers
in class Event
public static HandlerList getHandlerList()
Copyright © 2016. All rights reserved.