Class SGButton
java.lang.Object
com.samjakob.spigui.buttons.SGButton
An SGButton represents a clickable item in an SGMenu (GUI).
It consists of an icon (
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.
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 Summary
FieldsModifier and TypeFieldDescriptionprivate org.bukkit.inventory.ItemStackThe BukkitItemStackthat will be used as the button's icon.private SGButtonListenerThe on-click handler for this button. -
Constructor Summary
ConstructorsConstructorDescriptionSGButton(org.bukkit.inventory.ItemStack icon) Creates an SGButton with the specifiedItemStackas it's 'icon' in the inventory. -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.inventory.ItemStackgetIcon()Returns theItemStackthat will be used as the SGButton's icon in the SGMenu (GUI).Returns theSGButtonListenerthat is to be executed when the button is clicked.
This is typically intended for use by the API.voidsetIcon(org.bukkit.inventory.ItemStack icon) Changes the SGButton's icon.voidsetListener(SGButtonListener listener) Sets theSGButtonListenerto be called when the button is clicked.withListener(SGButtonListener listener) A chainable alias ofsetListener(SGButtonListener).
-
Field Details
-
listener
The on-click handler for this button. -
icon
private org.bukkit.inventory.ItemStack iconThe BukkitItemStackthat will be used as the button's icon.
-
-
Constructor Details
-
SGButton
public SGButton(org.bukkit.inventory.ItemStack icon) Creates an SGButton with the specifiedItemStackas it's 'icon' in the inventory.- Parameters:
icon- The desired 'icon' for the SGButton.
-
-
Method Details
-
setListener
Sets theSGButtonListenerto be called when the button is clicked.- Parameters:
listener- The listener to be called when the button is clicked.
-
withListener
A chainable alias ofsetListener(SGButtonListener).- Parameters:
listener- The listener to be called when the button is clicked.- Returns:
- The
SGButtonthe listener was applied to.
-
getListener
Returns theSGButtonListenerthat 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 theItemStackthat 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.
-