Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.event.inventory.InventoryDragEvent Class Reference
Inheritance diagram for org.bukkit.event.inventory.InventoryDragEvent:
org.bukkit.event.inventory.InventoryInteractEvent org.bukkit.event.inventory.InventoryEvent org.bukkit.event.Cancellable org.bukkit.event.Event

Public Member Functions

 InventoryDragEvent (InventoryView what, ItemStack newCursor, ItemStack oldCursor, boolean right, Map< Integer, ItemStack > slots)
Map< Integer, ItemStackgetNewItems ()
Set< Integer > getRawSlots ()
Set< Integer > getInventorySlots ()
ItemStack getCursor ()
void setCursor (ItemStack newCursor)
ItemStack getOldCursor ()
DragType getType ()
HandlerList getHandlers ()
- Public Member Functions inherited from org.bukkit.event.inventory.InventoryInteractEvent
 InventoryInteractEvent (InventoryView transaction)
HumanEntity getWhoClicked ()
void setResult (Result newResult)
Result getResult ()
boolean isCancelled ()
void setCancelled (boolean toCancel)
- Public Member Functions inherited from org.bukkit.event.inventory.InventoryEvent
 InventoryEvent (InventoryView transaction)
Inventory getInventory ()
List< HumanEntitygetViewers ()
InventoryView getView ()
HandlerList getHandlers ()
- Public Member Functions inherited from org.bukkit.event.Event
 Event ()
 Event (boolean isAsync)
String getEventName ()
abstract HandlerList getHandlers ()
final boolean isAsynchronous ()

Static Public Member Functions

static HandlerList getHandlerList ()
- Static Public Member Functions inherited from org.bukkit.event.inventory.InventoryEvent
static HandlerList getHandlerList ()

Additional Inherited Members

- Protected Attributes inherited from org.bukkit.event.inventory.InventoryEvent
InventoryView transaction

Detailed Description

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.

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.

Definition at line 57 of file InventoryDragEvent.java.

Member Function Documentation

ItemStack org.bukkit.event.inventory.InventoryDragEvent.getCursor ( )

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

the result cursor

Definition at line 116 of file InventoryDragEvent.java.

116  {
117  return newCursor;
118  }
Set<Integer> org.bukkit.event.inventory.InventoryDragEvent.getInventorySlots ( )

Gets the slots to be changed in this drag.

list of converted slot ids, suitable for org.bukkit.inventory.Inventory#getItem(int).

Definition at line 106 of file InventoryDragEvent.java.

106  {
107  return containerSlots;
108  }
Map<Integer, ItemStack> org.bukkit.event.inventory.InventoryDragEvent.getNewItems ( )

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

map from raw slot id to new ItemStack

Definition at line 87 of file InventoryDragEvent.java.

87  {
88  return Collections.unmodifiableMap(addedItems);
89  }
ItemStack org.bukkit.event.inventory.InventoryDragEvent.getOldCursor ( )

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

the original cursor

Definition at line 139 of file InventoryDragEvent.java.

139  {
140  return oldCursor.clone();
141  }
Set<Integer> org.bukkit.event.inventory.InventoryDragEvent.getRawSlots ( )

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

list of raw slot ids, suitable for getView().getItem(int)

Definition at line 96 of file InventoryDragEvent.java.

96  {
97  return addedItems.keySet();
98  }
DragType org.bukkit.event.inventory.InventoryDragEvent.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

Definition at line 152 of file InventoryDragEvent.java.

152  {
153  return type;
154  }
void org.bukkit.event.inventory.InventoryDragEvent.setCursor ( 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.

newCursorthe new cursor ItemStack

Definition at line 129 of file InventoryDragEvent.java.

129  {
130  this.newCursor = newCursor;
131  }

The documentation for this class was generated from the following file: