类 InventoryClickEvent
- 所有已实现的接口:
Cancellable
- 直接已知子类:
CraftItemEvent
,InventoryCreativeEvent
译注:事实上打开任意容器的物品栏(包括玩家的背包)后点击任何一个地方都会触发这个事件。
由于InventoryClickEvent
是通过修改物品栏
的实现类来触发的,所以并非所有与物品栏
相关的方法都是安全的。
下面这些属于HumanEntity
和 InventoryView
的方法不应该被处理
InventoryClickEvent
事件的 事件处理器
调用
HumanEntity.closeInventory()
HumanEntity.openInventory(Inventory)
HumanEntity.openWorkbench(Location, boolean)
HumanEntity.openEnchanting(Location, boolean)
InventoryView.close()
BukkitScheduler.runTask(Plugin, Runnable)
来执行
,这个方法将在下一个tick执行你的任务。注意:上面列出来的这些方法并不全,可能还有其它的方法也存在问题。
Assuming the EntityHuman associated with this event is an instance of a
Player, manipulating the MaxStackSize or contents of an Inventory will
require an Invocation of Player.updateInventory()
.
Modifications to slots that are modified by the results of this
InventoryClickEvent can be overwritten. To change these slots, this event
should be cancelled and all desired changes to the inventory applied.
Alternatively, scheduling a task using
BukkitScheduler.runTask(Plugin, Runnable)
, which would execute the
task on the next tick, would work as well.
-
嵌套类概要
从类继承的嵌套类/接口 org.bukkit.event.Event
Event.Result
-
字段概要
从类继承的字段 org.bukkit.event.inventory.InventoryEvent
transaction
-
构造器概要
构造器说明InventoryClickEvent
(InventoryView view, InventoryType.SlotType type, int slot, ClickType click, InventoryAction action) InventoryClickEvent
(InventoryView view, InventoryType.SlotType type, int slot, ClickType click, InventoryAction action, int key) -
方法概要
修饰符和类型方法说明Gets the InventoryAction that triggered this event.getClick()
获取本事件的ClickType.获取被点击的格子的物品获取当前光标所指的物品static HandlerList
int
如果ClickType是NUMVER_KEY(按下数字切换物品),这个方法将返回按下的键的索引(0-8)int
返回点击的原始格子序号,可传递给#getItem(int)
。int
getSlot()
返回点击的格子序号,可传递给Inventory.getItem(int)
。获取被点击的格子的类型.boolean
获取是否左击背包boolean
获取是否右击背包boolean
获取是否按住shift点击背包void
setCurrentItem
(ItemStack stack) Sets the ItemStack currently in the clicked slot.void
已过时。This changes the ItemStack in their hand before any calculations are applied to the Inventory, which has a tendency to create inconsistencies between the Player and the server, and to make unexpected changes in the behavior of the clicked Inventory.从类继承的方法 org.bukkit.event.inventory.InventoryInteractEvent
getResult, getWhoClicked, isCancelled, setCancelled, setResult
从类继承的方法 org.bukkit.event.inventory.InventoryEvent
getInventory, getView, getViewers
从类继承的方法 org.bukkit.event.Event
getEventName, isAsynchronous
-
构造器详细资料
-
InventoryClickEvent
public InventoryClickEvent(InventoryView view, InventoryType.SlotType type, int slot, ClickType click, InventoryAction action) -
InventoryClickEvent
public InventoryClickEvent(InventoryView view, InventoryType.SlotType type, int slot, ClickType click, InventoryAction action, int key)
-
-
方法详细资料
-
getSlotType
获取被点击的格子的类型.原文:Gets the type of slot that was clicked.
- 返回:
- 格子类型
-
getCursor
获取当前光标所指的物品原文:Gets the current ItemStack on the cursor.
- 返回:
- 光标上的物品
-
getCurrentItem
获取被点击的格子的物品原文:Gets the ItemStack currently in the clicked slot.
- 返回:
- 被点击的物品
-
isRightClick
public boolean isRightClick()获取是否右击背包原文: Gets whether or not the ClickType for this event represents a right click.
- 返回:
- 是否右击背包
- 另请参阅:
-
isLeftClick
public boolean isLeftClick()获取是否左击背包原文:Gets whether or not the ClickType for this event represents a left click.
- 返回:
- 是否左击背包
- 另请参阅:
-
isShiftClick
public boolean isShiftClick()获取是否按住shift点击背包原文:Gets whether the ClickType for this event indicates that the key was pressed down when the click was made.
- 返回:
- 是否使用Shift或Ctrl按键
- 另请参阅:
-
setCursor
已过时。This changes the ItemStack in their hand before any calculations are applied to the Inventory, which has a tendency to create inconsistencies between the Player and the server, and to make unexpected changes in the behavior of the clicked Inventory.Sets the item on the cursor.- 参数:
stack
- the new cursor item
-
setCurrentItem
Sets the ItemStack currently in the clicked slot.- 参数:
stack
- the item to be placed in the current slot
-
getSlot
public int getSlot()返回点击的格子序号,可传递给Inventory.getItem(int)
。注意由于连接两个不同背包的视图,可能两个格子都是同一个格子序号原文:The slot number that was clicked, ready for passing to
Inventory.getItem(int)
. Note that there may be two slots with the same slot number, since a view links two different inventories.- 返回:
- 格子序号
-
getRawSlot
public int getRawSlot()返回点击的原始格子序号,可传递给#getItem(int)
。这个序号对每个视图是唯一的。原文:The raw slot number clicked, ready for passing to
#getItem(int)
This slot number is unique for the view.- 返回:
- 格子序号
-
getHotbarButton
public int getHotbarButton()如果ClickType是NUMVER_KEY(按下数字切换物品),这个方法将返回按下的键的索引(0-8)原文:If the ClickType is NUMBER_KEY, this method will return the index of the pressed key (0-8).
- 返回:
- 按下的数字减1(范围0-8),如果不是NUMBER_KEY动作为-1
-
getAction
Gets the InventoryAction that triggered this event.This action cannot be changed, and represents what the normal outcome of the event will be. To change the behavior of this InventoryClickEvent, changes must be manually applied.
- 返回:
- the InventoryAction that triggered this event.
-
getClick
获取本事件的ClickType.???????????????
原文:Gets the ClickType for this event.
This is insulated against changes to the inventory by other plugins.
- 返回:
- 背包点击类型
-
getHandlers
- 覆盖:
getHandlers
在类中InventoryEvent
-
getHandlerList
-