Interfaces
GuiButton API
GuiButton and GuiButtonInterface methods in XaGUI 1.6.1.
GuiButton simple = new GuiButton(Material.DIAMOND);
GuiButton existing = new GuiButton(itemStack);Styling and behavior methods return the same GuiButton for chaining unless noted.
| Method | Purpose |
|---|---|
setName(String) | Set display name with & color codes. |
setLore(String...) / setLoreList(List<String>) | Replace lore. |
addLoreLine(String) / addLore(String...) / addLoreList(List<String>) | Append lore. |
clearLore() | Remove lore. |
setAmount(int) | Set stack size. |
addItemFlag(...) / removeItemFlag(...) | Change item flags. |
addEnchantment(Enchantment[, int]) | Add an unsafe enchantment. |
removeEnchantment(...) / removeAllEnchantments() | Remove enchantments. |
setDurability(short) | Set legacy durability. |
withListener(GuiClickInterface) | Handle button clicks. |
withRedirect(Supplier<GuiMenuInterface>) | Open another menu after the handler. |
withClickSound(Sound, float) | Set this button's sound. |
clone() | Clone its item and copy behavior references. |
Accessors include getIcon(), getItem(), getClickListener(), getClickSound(), and getClickSoundVolume(). setItem(ItemStack) replaces the item and returns void; callRedirect(Player) manually invokes a configured redirect.
GuiButton sword = new GuiButton(Material.IRON_SWORD)
.setName("&aStarter sword")
.setLore("&7Sharp and shiny", "", "&eClick to claim")
.addItemFlag(ItemFlag.HIDE_ENCHANTS)
.addEnchantment(Enchantment.SHARPNESS, 1)
.withClickSound(Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.7f)
.withListener(event -> {
event.getPlayer().getInventory().addItem(new ItemStack(Material.IRON_SWORD));
event.getPlayer().closeInventory();
});When reusing a template button, call clone() before changing its listener or metadata.