类 InventoryDragEvent

所有已实现的接口:
Cancellable

public class InventoryDragEvent extends InventoryInteractEvent
当玩家在物品栏中拖拽光标中的物品时调用此事件。ItemStack 将分布在 HumanEntity 拖拽过的槽位上。分布方式由 getType() 返回的 DragType 描述。

取消此事件将导致 getNewItems() 中描述的更改都不会应用到物品栏。

由于 InventoryDragEvent 发生在物品栏修改期间,并非所有与物品栏相关的方法都可以安全使用。

以下方法绝不应该由 InventoryDragEvent 的事件处理器使用与此事件关联的 HumanEntity 或 InventoryView 来调用。

要调用这些方法之一,请使用 BukkitScheduler.runTask(Plugin, Runnable) 安排任务,该任务将在下一个游戏刻运行。另请注意,此列表并非详尽无遗,其他方法也可能导致问题。

假设与此事件关联的 EntityHuman 是 Player 的实例,则操作物品栏的最大堆叠大小或内容将需要调用 Player.updateInventory()。

对由此 InventoryDragEvent 结果修改的槽位的任何更改都将被覆盖。要更改这些槽位,应取消此事件并应用更改。或者,使用 BukkitScheduler.runTask(Plugin, Runnable) 安排任务,该任务将在下一个游戏刻执行,也可以实现。

  • 构造器详细资料

  • 方法详细资料

    • getNewItems

      @NotNull public @NotNull Map<Integer,ItemStack> getNewItems()
      获取此次拖拽中将添加到物品栏的所有物品。
      返回:
      从原始槽位 ID 到新 ItemStack 的映射

      原文:Gets all items to be added to the inventory in this drag.

    • getRawSlots

      @NotNull public @NotNull Set<Integer> getRawSlots()
      获取此次拖拽中将被更改的原始槽位 ID。
      返回:
      原始槽位 ID 列表,适用于 getView().getItem(int)

      原文:Gets the raw slot ids to be changed in this drag.

    • getInventorySlots

      @NotNull public @NotNull Set<Integer> getInventorySlots()
      获取此次拖拽中将被更改的槽位。
      返回:
      转换后的槽位 ID 列表,适用于 Inventory.getItem(int)。

      原文:Gets the slots to be changed in this drag.

    • getCursor

      @Nullable public @Nullable ItemStack getCursor()
      获取拖拽完成后的结果光标。返回值是可变的。
      返回:
      结果光标

      原文:Gets the result cursor after the drag is done. The returned value is mutable.

    • setCursor

      public void setCursor(@Nullable @Nullable ItemStack newCursor)
      设置拖拽完成后的结果光标。

      更改此物品堆栈会更改光标物品。请注意,更改受影响的"拖拽"槽位不会更改此 ItemStack,更改此 ItemStack 也不会影响"拖拽"槽位。

      参数:
      newCursor - 新的光标 ItemStack

      原文:Sets the result cursor after the drag is done.

      Changing this item stack changes the cursor item. Note that changing the affected "dragged" slots does not change this ItemStack, nor does changing this ItemStack affect the "dragged" slots.

    • getOldCursor

      @NotNull public @NotNull ItemStack getOldCursor()
      获取一个 ItemStack,表示在此拖拽导致任何修改之前的光标。
      返回:
      原始光标

      原文:Gets an ItemStack representing the cursor prior to any modifications as a result of this drag.

    • getType

      @NotNull public @NotNull DragType getType()
      获取描述此 InventoryDragEvent 之后放置的 ItemStack 行为的 DragType。

      可以使用 getNewItems() 找到 ItemStack 及其应用的原始槽位。

      返回:
      此 InventoryDragEvent 的 DragType

      原文:Gets the DragType that describes the behavior of ItemStacks placed after this InventoryDragEvent.

      The ItemStacks and the raw slots that they're being applied to can be found using getNewItems().

    • getHandlers

      @NotNull public @NotNull HandlerList getHandlers()
      覆盖:
      getHandlers 在类中 InventoryEvent
    • getHandlerList

      @NotNull public static @NotNull HandlerList getHandlerList()