Class InventoryButton

java.lang.Object
io.github.lucfr1746.llibrary.inventory.InventoryButton
All Implemented Interfaces:
Cloneable

public class InventoryButton extends Object implements Cloneable
Represents a button in a custom inventory system. This button can have a dynamic icon, handle click events, and have visibility requirements.
  • Constructor Details

    • InventoryButton

      public InventoryButton()
  • Method Details

    • creator

      public InventoryButton creator(Function<org.bukkit.entity.Player,org.bukkit.inventory.ItemStack> iconCreator)
      Sets the function that generates the button's icon.
      Parameters:
      iconCreator - A function that takes a Player and returns an ItemStack.
      Returns:
      The current InventoryButton instance.
    • consumer

      public InventoryButton consumer(Consumer<org.bukkit.event.inventory.InventoryClickEvent> eventConsumer)
      Sets the consumer that handles inventory click events.
      Parameters:
      eventConsumer - A consumer that processes InventoryClickEvent.
      Returns:
      The current InventoryButton instance.
    • id

      public InventoryButton id(String id)
      Sets the identifier for the button.
      Parameters:
      id - A unique string identifier.
      Returns:
      The current InventoryButton instance.
    • priority

      public InventoryButton priority(int priority)
      Sets the priority of the button, which may be used for sorting.
      Parameters:
      priority - An integer representing the button's priority.
      Returns:
      The current InventoryButton instance.
    • viewRequirements

      public InventoryButton viewRequirements(List<Requirement> requirements)
      Sets the list of requirements that determine whether the button is visible.
      Parameters:
      requirements - A list of Requirement objects.
      Returns:
      The current InventoryButton instance.
    • getIconCreator

      public Function<org.bukkit.entity.Player,org.bukkit.inventory.ItemStack> getIconCreator()
      Gets the function that generates the button's icon.
      Returns:
      A function that takes a Player and returns an ItemStack.
    • getEventConsumer

      public Consumer<org.bukkit.event.inventory.InventoryClickEvent> getEventConsumer()
      Gets the consumer that handles inventory click events.
      Returns:
      A consumer that processes InventoryClickEvent.
    • getId

      public String getId()
      Gets the identifier of the button.
      Returns:
      A unique string identifier.
    • getPriority

      public int getPriority()
      Gets the priority of the button.
      Returns:
      An integer representing the button's priority.
    • clone

      public InventoryButton clone()
      Overrides:
      clone in class Object
    • getViewRequirements

      public List<Requirement> getViewRequirements()
      Gets the list of requirements that determine whether the button is visible.
      Returns:
      A list of Requirement objects.