Class SGButton

java.lang.Object
com.samjakob.spigui.buttons.SGButton

public class SGButton extends Object
An SGButton represents a clickable item in an SGMenu (GUI). It consists of an icon (ItemStack) and a listener (SGButton).
When the icon is clicked in the SGMenu, the listener is called, thus allowing for rudimentary menus to be built by displaying icons and overriding their behavior.
This somewhat resembles the point-and-click nature of Graphical User Interfaces (GUIs) popularized by Operating Systems developed in the late 80s and 90s which is where the name of the concept in Spigot plugins was derived.
  • Field Details

    • listener

      private SGButtonListener listener
      The on-click handler for this button.
    • icon

      private org.bukkit.inventory.ItemStack icon
      The Bukkit ItemStack that will be used as the button's icon.
  • Constructor Details

    • SGButton

      public SGButton(org.bukkit.inventory.ItemStack icon)
      Creates an SGButton with the specified ItemStack as it's 'icon' in the inventory.
      Parameters:
      icon - The desired 'icon' for the SGButton.
  • Method Details

    • setListener

      public void setListener(SGButtonListener listener)
      Sets the SGButtonListener to be called when the button is clicked.
      Parameters:
      listener - The listener to be called when the button is clicked.
    • withListener

      public SGButton withListener(SGButtonListener listener)
      A chainable alias of setListener(SGButtonListener).
      Parameters:
      listener - The listener to be called when the button is clicked.
      Returns:
      The SGButton the listener was applied to.
    • getListener

      public SGButtonListener getListener()
      Returns the SGButtonListener that is to be executed when the button is clicked.
      This is typically intended for use by the API.
      Returns:
      The listener to be called when the button is clicked.
    • getIcon

      public org.bukkit.inventory.ItemStack getIcon()
      Returns the ItemStack that will be used as the SGButton's icon in the SGMenu (GUI).
      Returns:
      The icon (ItemStack) that will be used to represent the button.
    • setIcon

      public void setIcon(org.bukkit.inventory.ItemStack icon)
      Changes the SGButton's icon.
      Parameters:
      icon - The icon (ItemStack) that will be used to represent the button.