Class ItemAction

java.lang.Object
net.joseplay.allianceutils.api.menu.ItemAction

public class ItemAction extends Object
Represents an item associated with a click action in a menu system.

This class binds an ItemStack to a Consumer that will be executed when the item is interacted with in an inventory.

Usage example:
 ItemAction action = new ItemAction(item, event -> {
     event.setCancelled(true);
     // handle click
 });
 
Notes:
  • The action is executed with the InventoryClickEvent
  • No null validation is performed
  • The ItemStack is stored by reference (not cloned)
  • Constructor Details

    • ItemAction

      public ItemAction(org.bukkit.inventory.ItemStack itemStack, Consumer<org.bukkit.event.inventory.InventoryClickEvent> action)
      Creates a new ItemAction.
      Parameters:
      itemStack - the item to associate with the action
      action - the logic to execute on click
  • Method Details

    • getItemStack

      public org.bukkit.inventory.ItemStack getItemStack()
      Returns the associated item.
      Returns:
      item stack
    • getAction

      public Consumer<org.bukkit.event.inventory.InventoryClickEvent> getAction()
      Returns the click action.
      Returns:
      consumer handling the click event