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 Summary

    Constructors
    Constructor
    Description
    ActionItem(org.bukkit.inventory.ItemStack itemStack, int slot, Consumer<org.bukkit.event.inventory.InventoryClickEvent> onClick, Consumer<@Nullable org.bukkit.inventory.ItemStack> onClose)
    Creates a new Action Item.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.inventory.ItemStack
     
    int
     
    void
    onInventoryClick(org.bukkit.event.inventory.InventoryClickEvent event)
    This method will be called for the clicked item stack and only for the clicked item stack.
    void
    onInventoryClose(org.bukkit.inventory.ItemStack itemStack)
    This method is called for each registered item stack individually when an inventory is closed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ActionItem

      public ActionItem(org.bukkit.inventory.ItemStack itemStack, int slot, Consumer<org.bukkit.event.inventory.InventoryClickEvent> onClick, Consumer<@Nullable org.bukkit.inventory.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 org.bukkit.inventory.ItemStack getItemStack()
    • getSlot

      public int getSlot()
    • onInventoryClose

      public void onInventoryClose(org.bukkit.inventory.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(org.bukkit.event.inventory.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