Class Button

java.lang.Object
de.clickism.clickgui.menu.Button

public class Button extends Object
Represents a button in a menu.
  • Field Details

    • icon

      protected Icon icon
      The icon of this button.
    • immovable

      protected boolean immovable
      Whether this button is immovable.
    • onClick

      protected BiConsumer<org.bukkit.event.inventory.InventoryClickEvent,MenuView> onClick
      The action to perform when this button is clicked.
  • Constructor Details

    • Button

      protected Button(Icon icon)
      Creates a new button with the specified icon.
      Parameters:
      icon - the icon
  • Method Details

    • handleClick

      protected void handleClick(org.bukkit.event.inventory.InventoryClickEvent event, MenuView view)
      Handles the click event for this button.
      Parameters:
      event - the click event
      view - the view
    • getIcon

      public Icon getIcon()
      Gets the icon of this button.
      Returns:
      the icon
    • setName

      public Button setName(@Colorized String name)
      Sets the name of this button's icon. See Icon.setName(String).
      Parameters:
      name - the name
      Returns:
      this button
    • setMaterial

      public Button setMaterial(org.bukkit.Material material)
      Sets the material of this button's icon. See Icon.setMaterial(Material).
      Parameters:
      material - the material
      Returns:
      this button
    • hideAttributes

      public Button hideAttributes()
      Hides the attributes of this button's icon. See Icon.hideAttributes().
      Returns:
      this button
    • hidePotionEffects

      public Button hidePotionEffects()
      Hides the potion effects of this button's icon. See Icon.hidePotionEffects().
      Returns:
      this button
    • hideAllAttributes

      public Button hideAllAttributes()
      Hides all attributes of this button's icon. See Icon.hideAllAttributes().
      Returns:
      this button
    • addEnchantmentGlint

      public Button addEnchantmentGlint()
      Adds an enchantment glint to this button's icon. See Icon.addEnchantmentGlint().
      Returns:
      this button
    • setLore

      public Button setLore(@Colorized String... lore)
      Sets the lore of this button's icon. See Icon.setLore(List).
      Parameters:
      lore - the lore
      Returns:
      this button
    • setLore

      public Button setLore(@Colorized List<String> lore)
      Sets the lore of this button's icon. See Icon.setLore(List).
      Parameters:
      lore - the lore
      Returns:
      this button
    • addLoreLine

      public Button addLoreLine(@Colorized String line)
      Adds a line to the lore of this button's icon. See Icon.addLoreLine(String).
      Parameters:
      line - the line
      Returns:
      this button
    • runIf

      public Button runIf(boolean condition, Consumer<Button> consumer)
      Runs the consumer on this button if the condition is true.
      Parameters:
      condition - the condition
      consumer - the consumer
      Returns:
      this button
    • setOnClick

      public Button setOnClick(ClickAction action)
      Sets the action to perform when this button is clicked.
      Parameters:
      action - the action
      Returns:
      this button
    • setOnClick

      public Button setOnClick(Consumer<org.bukkit.event.inventory.InventoryClickEvent> eventConsumer)
      Sets the action to perform when this button is clicked.
      Parameters:
      eventConsumer - the action
      Returns:
      this button
    • setMovable

      public Button setMovable()
      Marks this button as movable, allowing it to be moved and removed from the inventory.
      Returns:
      this button
    • applyToMeta

      public Button applyToMeta(Consumer<org.bukkit.inventory.meta.ItemMeta> consumer)
      Applies the consumer to the meta of this button's icon. See Icon.applyToMeta(Consumer).
      Parameters:
      consumer - the consumer
      Returns:
      this button
    • empty

      public static Button empty()
      Creates a button with an empty icon.
      Returns:
      the button
    • withIcon

      public static Button withIcon(Icon icon)
      Creates a button with the specified icon.
      Parameters:
      icon - the icon
      Returns:
      the button
    • withIcon

      public static Button withIcon(org.bukkit.inventory.ItemStack item)
      Creates a button with the specified item stack as the icon.
      Parameters:
      item - the item stack
      Returns:
      the button
    • withIcon

      public static Button withIcon(org.bukkit.Material material)
      Creates a button with the specified material as the icon.
      Parameters:
      material - the material
      Returns:
      the button
    • withIcon

      public static Button withIcon(Supplier<Icon> iconSupplier)
      Creates a button with the specified icon supplier.
      Parameters:
      iconSupplier - the icon supplier
      Returns:
      the button