程序包 org.bukkit.event.inventory

# 类 InventoryDragEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.inventory.InventoryEvent
org.bukkit.event.inventory.InventoryInteractEvent
org.bukkit.event.inventory.InventoryDragEvent

所有已实现的接口:
  `Cancellable`

public class InventoryDragEvent extends InventoryInteractEvent
This event is called when the player drags an item in their cursor across the inventory. The ItemStack is distributed across the slots the HumanEntity dragged over. The method of distribution is described by the DragType returned by `getType()`.

Canceling this event will result in none of the changes described in `getNewItems()` being applied to the Inventory.

Because InventoryDragEvent occurs within a modification of the Inventory, not all Inventory related methods are safe to use.

The following should never be invoked by an EventHandler for InventoryDragEvent using the HumanEntity or InventoryView associated with this event.

- `HumanEntity.closeInventory()`
- `HumanEntity.openInventory(Inventory)`
- `HumanEntity.openWorkbench(Location, boolean)`
- `HumanEntity.openEnchanting(Location, boolean)`
- `InventoryView.close()`

To invoke one of these methods, schedule a task using `BukkitScheduler.runTask(Plugin, Runnable)`, which will run the task on the next tick. Also be aware that this is not an exhaustive list, and other methods could potentially create issues as well.

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()`.

Any modifications to slots that are modified by the results of this InventoryDragEvent will be overwritten. To change these slots, this event should be cancelled and the changes 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`

- ## 构造器概要

  构造器
  构造器
  说明
  `InventoryDragEvent(@NotNull InventoryView what, @Nullable ItemStack newCursor, @NotNull ItemStack oldCursor, boolean right, @NotNull Map<Integer,ItemStack> slots)`

- ## 方法概要

  修饰符和类型
  方法
  说明
  `@Nullable ItemStack`
  `getCursor()`
  Gets the result cursor after the drag is done.
  `static @NotNull HandlerList`
  `getHandlerList()`
  `@NotNull HandlerList`
  `getHandlers()`
  `@NotNull Set<Integer>`
  `getInventorySlots()`
  Gets the slots to be changed in this drag.
  `@NotNull Map<Integer,ItemStack>`
  `getNewItems()`
  Gets all items to be added to the inventory in this drag.
  `@NotNull ItemStack`
  `getOldCursor()`
  Gets an ItemStack representing the cursor prior to any modifications as a result of this drag.
  `@NotNull Set<Integer>`
  `getRawSlots()`
  Gets the raw slot ids to be changed in this drag.
  `@NotNull DragType`
  `getType()`
  Gets the DragType that describes the behavior of ItemStacks placed after this InventoryDragEvent.
  `void`
  `setCursor(@Nullable ItemStack newCursor)`
  Sets the result cursor after the drag is done.

  ### 从类继承的方法 org.bukkit.event.inventory.InventoryInteractEvent

  `getResult, getWhoClicked, isCancelled, setCancelled, setResult`

  ### 从类继承的方法 org.bukkit.event.inventory.InventoryEvent

  `getInventory, getView, getViewers`

  ### 从类继承的方法 org.bukkit.event.Event

  `getEventName, isAsynchronous`

  ### 从类继承的方法 java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 构造器详细资料

  - ### InventoryDragEvent

    public InventoryDragEvent(@NotNull @NotNull InventoryView what, @Nullable @Nullable ItemStack newCursor, @NotNull @NotNull ItemStack oldCursor, boolean right, @NotNull @NotNull Map<Integer,ItemStack> slots)

- ## 方法详细资料

  - ### getNewItems

    @NotNull public @NotNull Map<Integer,ItemStack> getNewItems()
    Gets all items to be added to the inventory in this drag.
    返回:
      map from raw slot id to new ItemStack

  - ### getRawSlots

    @NotNull public @NotNull Set<Integer> getRawSlots()
    Gets the raw slot ids to be changed in this drag.
    返回:
      list of raw slot ids, suitable for getView().getItem(int)

  - ### getInventorySlots

    @NotNull public @NotNull Set<Integer> getInventorySlots()
    Gets the slots to be changed in this drag.
    返回:
      list of converted slot ids, suitable for `Inventory.getItem(int)`.

  - ### getCursor

    @Nullable public @Nullable ItemStack getCursor()
    Gets the result cursor after the drag is done. The returned value is mutable.
    返回:
      the result cursor

  - ### setCursor

    public void setCursor(@Nullable @Nullable ItemStack newCursor)
    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.

    参数:
      `newCursor` - the new cursor ItemStack

  - ### getOldCursor

    @NotNull public @NotNull ItemStack getOldCursor()
    Gets an ItemStack representing the cursor prior to any modifications as a result of this drag.
    返回:
      the original cursor

  - ### getType

    @NotNull public @NotNull DragType getType()
    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()`.

    返回:
      the DragType of this InventoryDragEvent

  - ### getHandlers

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

  - ### getHandlerList

    @NotNull public static @NotNull HandlerList getHandlerList()