Class ActionItem

java.lang.Object
de.eldoria.eldoutilities.inventory.ActionItem

public class ActionItem extends Object
A class which represents an item in a slot which will execute actions on click on the item and on close of the inventory.
Since:
1.1.1
  • Constructor Details

    • ActionItem

      public ActionItem(ItemStack itemStack, int slot, Consumer<InventoryClickEvent> onClick, Consumer<@Nullable ItemStack> onClose)
      Creates a new Action Item. A action item will be passed to the InventoryActions wrapper.

      The itemStack will be inserted at the given slot and will not leave this slot until the inventory is closed.

      Parameters:
      itemStack - item for the action
      slot - position of the item
      onClick - This consumer will be called for the clicked item stack and only for the clicked item stack.

      It will be only called when the item stack is clicked and not when another item stack inside this inventory is clicked.

      The click event will be canceled after forwarding it to the action item.

      onClose - This method is called for each registered item stack individually when an inventory is closed.

      The event will not be passed.

      Use this method to save the settings.

  • Method Details

    • getItemStack

      public ItemStack getItemStack()
    • getSlot

      public int getSlot()
    • onInventoryClose

      public void onInventoryClose(ItemStack itemStack)
      This method is called for each registered item stack individually when an inventory is closed.

      The event will not be passed.

      Use this method to save the settings.

      Parameters:
      itemStack - item stack in the closed inventory.
    • onInventoryClick

      public void onInventoryClick(InventoryClickEvent event)
      This method will be called for the clicked item stack and only for the clicked item stack.

      It will be only called when the item stack is clicked and not when another item stack inside this inventory is clicked.

      The click event will be canceled after forwarding it to the action item.

      Parameters:
      event - click event of the clicked item stack