### Complete GuiManager Example Source: https://github.com/huanmeng-qwq/gui/blob/master/_autodocs/api-reference/GuiManager.md This example demonstrates the full setup and usage of GuiManager, including plugin enablement, GUI creation with custom slots and items, and opening the GUI for a player. ```java import me.huanmeng.gui.gui.GuiManager; import me.huanmeng.gui.gui.impl.GuiCustom; import me.huanmeng.gui.gui.button.Button; import me.huanmeng.gui.gui.slot.Slot; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; public class MyPlugin extends JavaPlugin { private GuiManager guiManager; @Override public void onEnable() { guiManager = new GuiManager(this); } @Override public void onDisable() { if (guiManager != null) { guiManager.close(); } } public void openCustomGui(Player player) { GuiCustom gui = new GuiCustom(player); gui.line(3); gui.title("Custom GUI"); gui.draw().set(Slot.of(0), Button.of(new ItemStack(Material.DIAMOND))); gui.openGui(); } } ``` -------------------------------- ### Example: Get Button Display Item Source: https://github.com/huanmeng-qwq/gui/blob/master/_autodocs/api-reference/Button.md An example demonstrating how to retrieve the ItemStack for a button. ```java ItemStack displayItem = button.getShowItem(player); ``` -------------------------------- ### Example: Create GuiPage and configure manually Source: https://github.com/huanmeng-qwq/gui/blob/master/_autodocs/api-reference/GuiPage.md This example shows the creation of a GuiPage instance and the subsequent manual configuration of player, items, and slots before applying page settings and opening the GUI. ```java GuiPage gui = new GuiPage(); gui.setPlayer(player); gui.allItems = itemList; gui.elementSlots = slots; gui.pageSetting(PageSettings.normal(gui)); gui.openGui(); ``` -------------------------------- ### Complete Bukkit GUI Plugin Example Source: https://github.com/huanmeng-qwq/gui/blob/master/_autodocs/README.md A full example demonstrating how to set up and use the Bukkit GUI library within a Spigot plugin. Includes GUI creation, button placement, and event handling. ```java import me.huanmeng.gui.gui.GuiManager; import me.huanmeng.gui.gui.impl.GuiCustom; import me.huanmeng.gui.gui.button.Button; import me.huanmeng.gui.gui.slot.Slot; import me.huanmeng.gui.gui.slot.Slots; import me.huanmeng.gui.gui.enums.Result; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; public class MyPlugin extends JavaPlugin { private GuiManager guiManager; @Override public void onEnable() { guiManager = new GuiManager(this); } @Override public void onDisable() { if (guiManager != null) { guiManager.close(); } } public void openMainMenu(Player player) { GuiCustom gui = new GuiCustom(player); gui.line(3); gui.title("§6Main Menu"); // Border ItemStack barrier = new ItemStack(Material.BARRIER); gui.draw().set(Slots.ofPattern( "BBBBBBBBB", "BOOOOOOB", "BBBBBBBBB" ), Button.of(barrier)); // Play button gui.draw().set(Slot.of(13), Button.ofPlayerClick( new ItemStack(Material.DIAMOND), player -> { player.sendMessage("Opening game..."); openGame(player); } )); // Close button gui.draw().set(Slot.ofBukkit(2, 8), Button.of( new ItemStack(Material.BARRIER), clickData -> Result.CANCEL_CLOSE )); gui.openGui(); } private void openGame(Player player) { // Game GUI setup... } } ``` -------------------------------- ### Complete Inventory Viewer GUI Example Source: https://github.com/huanmeng-qwq/gui/blob/master/_autodocs/api-reference/GuiPage.md An example demonstrating how to create a paginated GUI to view a player's inventory. It converts inventory items into buttons and sets up pagination with navigation controls. ```java import me.huanmeng.gui.gui.impl.GuiPage; import me.huanmeng.gui.gui.impl.page.PageSettings; import me.huanmeng.gui.gui.button.Button; import me.huanmeng.gui.gui.slot.Slots; public class InventoryViewerGui { public static void viewInventory(Player viewer, Player target) { // Convert inventory items to buttons List