CancellableCraftItemEvent, InventoryCreativeEventpublic class InventoryClickEvent extends InventoryInteractEvent
Because InventoryClickEvent 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 InventoryClickEvent using the HumanEntity or InventoryView associated with this event:
HumanEntity.closeInventory()
 HumanEntity.openInventory(Inventory)
 HumanEntity.openWorkbench(Location, boolean)
 HumanEntity.openEnchanting(Location, boolean)
 InventoryView.close()
 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().
 
 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.
Event.Resulttransaction| Constructor | Description | 
|---|---|
| InventoryClickEvent(@NotNull InventoryView view,
                   @NotNull InventoryType.SlotType type,
                   int slot,
                   @NotNull ClickType click,
                   @NotNull InventoryAction action) | |
| InventoryClickEvent(@NotNull InventoryView view,
                   @NotNull InventoryType.SlotType type,
                   int slot,
                   @NotNull ClickType click,
                   @NotNull InventoryAction action,
                   int key) | 
| Modifier and Type | Method | Description | 
|---|---|---|
| @NotNull InventoryAction | getAction() | Gets the InventoryAction that triggered this event. | 
| @NotNull ClickType | getClick() | Gets the ClickType for this event. | 
| @Nullable Inventory | getClickedInventory() | Gets the inventory corresponding to the clicked slot. | 
| @Nullable ItemStack | getCurrentItem() | Gets the ItemStack currently in the clicked slot. | 
| @Nullable ItemStack | getCursor() | Gets the current ItemStack on the cursor. | 
| static @NotNull HandlerList | getHandlerList() | |
| @NotNull HandlerList | getHandlers() | |
| int | getHotbarButton() | If the ClickType is NUMBER_KEY, this method will return the index of
 the pressed key (0-8). | 
| int | getRawSlot() | The raw slot number clicked, ready for passing to  #getItem(int)This slot number is unique for the view. | 
| int | getSlot() | The slot number that was clicked, ready for passing to
  Inventory.getItem(int). | 
| @NotNull InventoryType.SlotType | getSlotType() | Gets the type of slot that was clicked. | 
| boolean | isLeftClick() | Gets whether or not the ClickType for this event represents a left
 click. | 
| boolean | isRightClick() | Gets whether or not the ClickType for this event represents a right
 click. | 
| boolean | isShiftClick() | Gets whether the ClickType for this event indicates that the key was
 pressed down when the click was made. | 
| void | setCurrentItem(@Nullable ItemStack stack) | Sets the ItemStack currently in the clicked slot. | 
| void | setCursor(@Nullable ItemStack stack) | Deprecated. 
 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. | 
getEventName, isAsynchronousgetInventory, getView, getViewersgetResult, getWhoClicked, isCancelled, setCancelled, setResultpublic InventoryClickEvent(@NotNull
                           @NotNull InventoryView view,
                           @NotNull
                           @NotNull InventoryType.SlotType type,
                           int slot,
                           @NotNull
                           @NotNull ClickType click,
                           @NotNull
                           @NotNull InventoryAction action)
public InventoryClickEvent(@NotNull
                           @NotNull InventoryView view,
                           @NotNull
                           @NotNull InventoryType.SlotType type,
                           int slot,
                           @NotNull
                           @NotNull ClickType click,
                           @NotNull
                           @NotNull InventoryAction action,
                           int key)
@NotNull public @NotNull InventoryType.SlotType getSlotType()
@Nullable public @Nullable ItemStack getCursor()
@Nullable public @Nullable ItemStack getCurrentItem()
public boolean isRightClick()
ClickType.isRightClick()public boolean isLeftClick()
ClickType.isLeftClick()public boolean isShiftClick()
ClickType.isShiftClick()@Deprecated public void setCursor(@Nullable @Nullable ItemStack stack)
stack - the new cursor itempublic void setCurrentItem(@Nullable
                           @Nullable ItemStack stack)
stack - the item to be placed in the current slot@Nullable public @Nullable Inventory getClickedInventory()
InventoryView.getInventory(int)public int getSlot()
Inventory.getItem(int). Note that there may be two slots with
 the same slot number, since a view links two different inventories.public int getRawSlot()
#getItem(int) This slot number is unique for the view.public int getHotbarButton()
@NotNull public @NotNull InventoryAction getAction()
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.
@NotNull public @NotNull ClickType getClick()
This is insulated against changes to the inventory by other plugins.
@NotNull public @NotNull HandlerList getHandlers()
getHandlers in class InventoryEvent@NotNull public static @NotNull HandlerList getHandlerList()
Copyright © 2020. All rights reserved.