类 PlayerInteractEvent
- 所有已实现的接口:
Cancellable
你可以使用 getHand()
方法来确定是哪只手
如果是原版行为触发了本事件, 则本事件将会被取消(例如与空气进行交互)
原文:Represents an event that is called when a player interacts with an object or
air, potentially fired once for each hand. The hand can be determined using
getHand()
.
This event will fire as cancelled if the vanilla behavior is to do nothing (e.g interacting with air)
-
嵌套类概要
从类继承的嵌套类/接口 org.bukkit.event.Event
Event.Result
-
字段概要
从类继承的字段 org.bukkit.event.player.PlayerEvent
player
-
构造器概要
构造器说明PlayerInteractEvent
(Player who, Action action, ItemStack item, Block clickedBlock, BlockFace clickedFace) PlayerInteractEvent
(Player who, Action action, ItemStack item, Block clickedBlock, BlockFace clickedFace, EquipmentSlot hand) -
方法概要
修饰符和类型方法说明获取本次交互的类型返回被点击的方块的朝向返回被点击的方块getHand()
static HandlerList
getItem()
获取本事件玩家手中的物品, 手中物品为空时会返回null方便的方法, 返回由此事件表示的物品的材质 原文:Convenience method.boolean
hasBlock()
检查这个事件是否涉及到一个方块 原文:Check if this event involved a blockboolean
hasItem()
检查这个事件是否涉及一个物品 原文:Check if this event involved an itemboolean
返回这个事件触发是否由放置方块所触发的boolean
获取本事件的取消状态.void
setCancelled
(boolean cancel) 设置本事件的取消状态, 取消的事件不会在服务器中执行, 但仍然会传递给其他插件对本事件的监听void
setUseInteractedBlock
(Event.Result useInteractedBlock) void
setUseItemInHand
(Event.Result useItemInHand) 该方法会得到在对方块进行点击后(如果有的话)所采取的动作.该方法会得到玩家拿着的物品的动作.从类继承的方法 org.bukkit.event.player.PlayerEvent
getPlayer
从类继承的方法 org.bukkit.event.Event
getEventName, isAsynchronous
-
字段详细资料
-
item
-
action
-
blockClicked
-
blockFace
-
-
构造器详细资料
-
PlayerInteractEvent
-
PlayerInteractEvent
-
-
方法详细资料
-
getAction
获取本次交互的类型原文:Returns the action type
- 返回:
- Action 返回交互的类型
-
isCancelled
public boolean isCancelled()获取本事件的取消状态.原文:Gets the cancellation state of this event. Set to true if you want to prevent buckets from placing water and so forth
- 指定者:
isCancelled
在接口中Cancellable
- 返回:
- boolean 取消状态
-
setCancelled
public void setCancelled(boolean cancel) 设置本事件的取消状态, 取消的事件不会在服务器中执行, 但仍然会传递给其他插件对本事件的监听取消这个事件将会阻止玩家吃东西(玩家不会失去食物), 阻止弓箭/雪球/蛋发射...(玩家不会失去弹药)
原文:Sets the cancellation state of this event. A canceled event will not be executed in the server, but will still pass to other plugins
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
在接口中Cancellable
- 参数:
cancel
- 设置为 true 时将会阻止本事件触发
-
getItem
获取本事件玩家手中的物品, 手中物品为空时会返回null原文:Returns the item in hand represented by this event
- 返回:
- ItemStack 使用的物品
-
getMaterial
方便的方法, 返回由此事件表示的物品的材质 原文:Convenience method. Returns the material of the item represented by this event- 返回:
- Material 所用物品的材质
-
hasBlock
public boolean hasBlock()检查这个事件是否涉及到一个方块 原文:Check if this event involved a block- 返回:
- boolean 如果涉及到则返回true
-
hasItem
public boolean hasItem()检查这个事件是否涉及一个物品 原文:Check if this event involved an item- 返回:
- boolean 如果涉及到则返回true
-
isBlockInHand
public boolean isBlockInHand()返回这个事件触发是否由放置方块所触发的原文:Convenience method to inform the user whether this was a block placement event.
- 返回:
- boolean 如果手中的物品是一个方块,则为true
-
getClickedBlock
返回被点击的方块原文:Returns the clicked block
- 返回:
- Block 点击的方块
-
getBlockFace
返回被点击的方块的朝向Returns the face of the block that was clicked
- 返回:
- BlockFace 被点击的方块的朝向
-
useInteractedBlock
该方法会得到在对方块进行点击后(如果有的话)所采取的动作.这个事件将会处理所有被点击的方块, 但是大多数的方块都没有默认的动作.
原文:This event gets processed for all blocks, but most don't have a default action 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
- 返回:
- 被交互的方块进行的动作
-
setUseInteractedBlock
- 参数:
useInteractedBlock
- 被交互的方块进行的动作
-
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.
- 返回:
- 手中的物品采取的行动
-
setUseItemInHand
- 参数:
useItemInHand
- 手中的物品采取的行动
-
getHand
获取用来执行本次交互的手, 但当Action.PHYSICAL
时可能为空 译注:也就是getAction()
为Action.PHYSICAL
时The hand used to perform this interaction. May be null in the case of
Action.PHYSICAL
.- 返回:
- 用来交互的手, 可能为null。
-
getHandlers
- 指定者:
getHandlers
在类中Event
-
getHandlerList
-