Class ItemButton

java.lang.Object
redempt.redlib.inventorygui.ItemButton

public abstract class ItemButton extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.bukkit.inventory.ItemStack
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemButton(org.bukkit.inventory.ItemStack item)
    Create a new ItemButton with the given ItemStack as the icon
  • Method Summary

    Modifier and Type
    Method
    Description
    static ItemButton
    create(org.bukkit.inventory.ItemStack item, BiConsumer<org.bukkit.event.inventory.InventoryClickEvent,ItemButton> listener)
    Create an ItemButton from the given ItemStack and listener.
    static ItemButton
    create(org.bukkit.inventory.ItemStack item, Consumer<org.bukkit.event.inventory.InventoryClickEvent> listener)
    Create an ItemButton from the given ItemStack and listener.
    org.bukkit.inventory.ItemStack
    Get the ItemStack representing the icon for this button
    protected int
     
    abstract void
    onClick(org.bukkit.event.inventory.InventoryClickEvent e)
     
    void
    setItem(org.bukkit.inventory.ItemStack item)
    Update the item of this button.
    protected void
    setSlot(int slot)
     

    Methods inherited from class java.lang.Object

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

    • item

      protected org.bukkit.inventory.ItemStack item
  • Constructor Details

    • ItemButton

      public ItemButton(org.bukkit.inventory.ItemStack item)
      Create a new ItemButton with the given ItemStack as the icon
      Parameters:
      item - The ItemStack to be used as the icon
  • Method Details

    • create

      public static ItemButton create(org.bukkit.inventory.ItemStack item, Consumer<org.bukkit.event.inventory.InventoryClickEvent> listener)
      Create an ItemButton from the given ItemStack and listener. Useful if you, like most people, would rather use lambdas than the anonymous class definition.
      Parameters:
      item - The ItemStack to be used as this button's icon
      listener - The listener which will be called whenever this button is clicked
      Returns:
      The ItemButton, which can be added to an InventoryGUI
    • create

      public static ItemButton create(org.bukkit.inventory.ItemStack item, BiConsumer<org.bukkit.event.inventory.InventoryClickEvent,ItemButton> listener)
      Create an ItemButton from the given ItemStack and listener. Useful if you, like most people, would rather use lambdas than the anonymous class definition.
      Parameters:
      item - The ItemStack to be used as this button's icon
      listener - The listener which will be called whenever this button is clicked and accepts the event and button
      Returns:
      The ItemButton, which can be added to an InventoryGUI
    • getItem

      public org.bukkit.inventory.ItemStack getItem()
      Get the ItemStack representing the icon for this button
      Returns:
      The ItemStack
    • getSlot

      protected int getSlot()
    • setSlot

      protected void setSlot(int slot)
    • setItem

      public void setItem(org.bukkit.inventory.ItemStack item)
      Update the item of this button. Does not refresh the InventoryGUI; you must call InventoryGUI.update() for this change to be reflected in the GUI.
      Parameters:
      item - The item to become the icon for this button
    • onClick

      public abstract void onClick(org.bukkit.event.inventory.InventoryClickEvent e)