|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bukkit.event.Event org.bukkit.event.player.PlayerEvent org.bukkit.event.player.PlayerInteractEvent
public class PlayerInteractEvent
Called when a player interacts with an object or air.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.bukkit.event.Event |
---|
Event.Result |
Field Summary | |
---|---|
protected Action |
action
|
protected Block |
blockClicked
|
protected BlockFace |
blockFace
|
protected ItemStack |
item
|
Fields inherited from class org.bukkit.event.player.PlayerEvent |
---|
player |
Constructor Summary | |
---|---|
PlayerInteractEvent(Player who,
Action action,
ItemStack item,
Block clickedBlock,
BlockFace clickedFace)
|
Method Summary | |
---|---|
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 This event gets processed for all blocks, but most don't have a default action |
Event.Result |
useItemInHand()
This controls the action to take with the item the player is holding This includes both blocks and items (such as flint and steel or records) When this is set to default, it will be allowed if no action is taken on the interacted block |
Methods inherited from class org.bukkit.event.player.PlayerEvent |
---|
getPlayer |
Methods inherited from class org.bukkit.event.Event |
---|
getEventName, isAsynchronous |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ItemStack item
protected Action action
protected Block blockClicked
protected BlockFace blockFace
Constructor Detail |
---|
public PlayerInteractEvent(Player who, Action action, ItemStack item, Block clickedBlock, BlockFace clickedFace)
Method Detail |
---|
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()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |