### Configure GUI with apply() Source: https://context7.com/triumphteam/triumph-gui/llms.txt Demonstrates applying inline configuration logic and using a reusable Consumer to standardize GUI behavior across multiple instances. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.builder.item.ItemBuilder; import net.kyori.adventure.text.Component; import org.bukkit.Material; // Apply default configuration Gui gui = Gui.gui() .title(Component.text("Configured Menu")) .rows(3) .disableAllInteractions() .apply(menu -> { // Add default items GuiItem border = ItemBuilder.from(Material.BLACK_STAINED_GLASS_PANE) .name(Component.text(" ")) .asGuiItem(); menu.getFiller().fillBorder(border); // Set default actions menu.setDefaultClickAction(event -> { event.setCancelled(true); }); menu.setCloseGuiAction(event -> { // Save data on close }); }) .create(); // Reusable menu configuration Consumer defaultConfig = menu -> { menu.getFiller().fillBorder( ItemBuilder.from(Material.GRAY_STAINED_GLASS_PANE) .name(Component.text(" ")) .asGuiItem() ); menu.setDefaultClickAction(event -> event.setCancelled(true)); }; Gui menu1 = Gui.gui() .title(Component.text("Menu 1")) .rows(6) .apply(defaultConfig) .create(); Gui menu2 = Gui.gui() .title(Component.text("Menu 2")) .rows(4) .apply(defaultConfig) .create(); ``` -------------------------------- ### Implement Paginated GUI Source: https://context7.com/triumphteam/triumph-gui/llms.txt Shows how to configure a PaginatedGui, add navigation controls, and populate items that automatically distribute across pages. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.guis.PaginatedGui; import dev.triumphteam.gui.guis.GuiItem; import dev.triumphteam.gui.builder.item.ItemBuilder; import net.kyori.adventure.text.Component; import org.bukkit.Material; // Create paginated GUI PaginatedGui gui = Gui.paginated() .title(Component.text("Item Shop - Page %page%")) .rows(6) .disableAllInteractions() .create(); // Add border decoration (these slots won't be used for page items) GuiItem border = ItemBuilder.from(Material.BLACK_STAINED_GLASS_PANE) .name(Component.text(" ")) .asGuiItem(); gui.getFiller().fillBorder(border); // Add navigation buttons in the bottom row GuiItem previousPage = ItemBuilder.from(Material.ARROW) .name(Component.text("Previous Page")) .asGuiItem(event -> gui.previous()); GuiItem nextPage = ItemBuilder.from(Material.ARROW) .name(Component.text("Next Page")) .asGuiItem(event -> gui.next()); GuiItem pageInfo = ItemBuilder.from(Material.PAPER) .name(Component.text("Page " + gui.getCurrentPageNum() + "/" + gui.getPagesNum())) .asGuiItem(); gui.setItem(6, 3, previousPage); // Row 6, Column 3 gui.setItem(6, 5, pageInfo); // Row 6, Column 5 gui.setItem(6, 7, nextPage); // Row 6, Column 7 // Add many items - they auto-paginate into available slots for (int i = 1; i <= 100; i++) { final int itemNumber = i; GuiItem item = ItemBuilder.from(Material.DIAMOND) .name(Component.text("Item #" + i)) .amount(Math.min(i, 64)) .asGuiItem(event -> { Player player = (Player) event.getWhoClicked(); player.sendMessage("You selected item #" + itemNumber); }); gui.addItem(item); // Adds to page items, not fixed slots } // Open at specific page Player player = ...; gui.open(player, 1); // Opens at page 1 // Page navigation methods gui.next(); // Go to next page (returns false if already on last) gui.previous(); // Go to previous page (returns false if already on first) int currentPage = gui.getCurrentPageNum(); int totalPages = gui.getPagesNum(); ``` -------------------------------- ### Create Basic Chest GUI with Clickable Item Source: https://context7.com/triumphteam/triumph-gui/llms.txt Demonstrates creating a standard chest GUI with a title, specific rows, and disabling interactions. Includes adding a clickable item that closes the inventory when clicked. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.guis.GuiItem; import dev.triumphteam.gui.builder.item.ItemBuilder; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Player; // Create a 3-row GUI with a title Gui gui = Gui.gui() .title(Component.text("My First GUI")) .rows(3) .disableAllInteractions() // Prevent players from taking items .create(); // Create a clickable item GuiItem closeButton = ItemBuilder.from(Material.BARRIER) .name(Component.text("Close Menu")) .lore(Component.text("Click to close")) .asGuiItem(event -> { event.getWhoClicked().closeInventory(); }); // Set item at specific slot (slot 13 = center of row 2) gui.setItem(13, closeButton); // Open GUI for a player Player player = ...; // Get player reference gui.open(player); ``` -------------------------------- ### Create Specialized Inventory GUIs Source: https://context7.com/triumphteam/triumph-gui/llms.txt Demonstrates initializing different inventory types such as hoppers, dispensers, workbenches, and brewing stands using the GuiType enum. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.components.GuiType; import net.kyori.adventure.text.Component; // Hopper GUI (5 slots) Gui hopperGui = Gui.gui(GuiType.HOPPER) .title(Component.text("Hopper Menu")) .disableAllInteractions() .create(); // Dispenser/Dropper GUI (3x3 = 9 slots) Gui dispenserGui = Gui.gui(GuiType.DISPENSER) .title(Component.text("Dispenser Menu")) .disableAllInteractions() .create(); // Workbench GUI (3x3 + output slot) Gui workbenchGui = Gui.gui(GuiType.WORKBENCH) .title(Component.text("Crafting Menu")) .disableAllInteractions() .create(); // Brewing stand GUI Gui brewingGui = Gui.gui(GuiType.BREWING) .title(Component.text("Brewing Menu")) .disableAllInteractions() .create(); // Standard chest with type method Gui chestGui = Gui.gui() .title(Component.text("Chest Menu")) .rows(6) // 1-6 rows for chest type .type(GuiType.CHEST) // Optional, CHEST is default .create(); ``` -------------------------------- ### Implement Persistent Storage GUIs Source: https://context7.com/triumphteam/triumph-gui/llms.txt Creates a GUI that retains items across sessions. Use getInventory().getContents() and setContents() to handle data persistence. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.guis.StorageGui; import dev.triumphteam.gui.builder.item.ItemBuilder; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import java.util.Map; // Create storage GUI - items persist when closed StorageGui storageGui = Gui.storage() .title(Component.text("Personal Vault")) .rows(4) .enableAllInteractions() // Allow players to place/take items .create(); // Add decorative border that players can't interact with GuiItem border = ItemBuilder.from(Material.BLACK_STAINED_GLASS_PANE) .name(Component.text(" ")) .asGuiItem(); storageGui.getFiller().fillBorder(border); // Disable interactions only for border slots by adding items with no action // The center slots remain fully interactive for storage // Add items programmatically (returns leftover items if full) ItemStack diamond = new ItemStack(Material.DIAMOND, 32); ItemStack gold = new ItemStack(Material.GOLD_INGOT, 64); Map leftovers = storageGui.addItem(diamond, gold); if (!leftovers.isEmpty()) { player.sendMessage("Storage is full! Some items couldn't be added."); } // Save contents when needed ItemStack[] contents = storageGui.getInventory().getContents(); // Store 'contents' to database or file // Load contents on next open storageGui.getInventory().setContents(savedContents); storageGui.open(player); ``` -------------------------------- ### Manage GUI Opening and Closing Source: https://context7.com/triumphteam/triumph-gui/llms.txt Handle close actions, open GUIs for players, and manage programmatic closing or page navigation. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.guis.PaginatedGui; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; Gui gui = Gui.gui() .title(Component.text("My Menu")) .rows(3) .disableAllInteractions() .create(); // Set close action gui.setCloseGuiAction(event -> { Player player = (Player) event.getPlayer(); player.sendMessage("Menu closed!"); }); // Open GUI for player Player player = ...; gui.open(player); // Close with action (triggers close action) gui.close(player); // Close without triggering close action gui.close(player, false); // For paginated GUI - open at specific page PaginatedGui paginatedGui = Gui.paginated() .title(Component.text("Paginated Menu")) .rows(6) .create(); paginatedGui.open(player); // Opens at page 1 paginatedGui.open(player, 3); // Opens at page 3 // Check if GUI is updating (useful in event handlers) if (!gui.isUpdating()) { // Safe to perform actions } // Set updating flag manually gui.setUpdating(true); // ... perform batch updates ... gui.setUpdating(false); ``` -------------------------------- ### Apply GUI Filler Patterns Source: https://context7.com/triumphteam/triumph-gui/llms.txt Utilizes the GuiFiller class to apply decorative patterns to GUI backgrounds, including borders, rows, and specific regions. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.guis.BaseGui; import dev.triumphteam.gui.builder.item.ItemBuilder; import dev.triumphteam.gui.components.util.GuiFiller; import net.kyori.adventure.text.Component; import org.bukkit.Material; import java.util.Arrays; Gui gui = Gui.gui() .title(Component.text("Decorated Menu")) .rows(6) .disableAllInteractions() .create(); GuiItem filler = ItemBuilder.from(Material.GRAY_STAINED_GLASS_PANE) .name(Component.text(" ")) .asGuiItem(); GuiItem altFiller = ItemBuilder.from(Material.BLACK_STAINED_GLASS_PANE) .name(Component.text(" ")) .asGuiItem(); // Fill entire background gui.getFiller().fill(filler); // Fill only the border (top, bottom, left, right edges) gui.getFiller().fillBorder(filler); // Fill with alternating items gui.getFiller().fillBorder(Arrays.asList(filler, altFiller)); // Fill top row only gui.getFiller().fillTop(filler); // Fill bottom row only gui.getFiller().fillBottom(filler); // Fill left or right side gui.getFiller().fillSide(GuiFiller.Side.LEFT, Arrays.asList(filler)); gui.getFiller().fillSide(GuiFiller.Side.RIGHT, Arrays.asList(filler)); gui.getFiller().fillSide(GuiFiller.Side.BOTH, Arrays.asList(filler)); // Fill a rectangular region (row1, col1, row2, col2) gui.getFiller().fillBetweenPoints(2, 2, 5, 8, filler); gui.open(player); ``` -------------------------------- ### Handling GUI Events and Actions Source: https://context7.com/triumphteam/triumph-gui/llms.txt Implement event listeners for clicks, drags, and GUI lifecycle events, or attach actions directly to specific items. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.builder.item.ItemBuilder; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; Gui gui = Gui.gui() .title(Component.text("Event Demo")) .rows(3) .disableAllInteractions() .create(); // Action when clicking any slot gui.setDefaultClickAction(event -> { Player player = (Player) event.getWhoClicked(); player.sendMessage("Clicked slot: " + event.getSlot()); }); // Action when clicking only in the top inventory (the GUI itself) gui.setDefaultTopClickAction(event -> { // Only triggers for clicks in the GUI, not player inventory }); // Action when clicking in the player's inventory while GUI is open gui.setPlayerInventoryAction(event -> { event.setCancelled(true); Player player = (Player) event.getWhoClicked(); player.sendMessage("Can't use inventory items here!"); }); // Action when clicking outside the GUI window gui.setOutsideClickAction(event -> { Player player = (Player) event.getWhoClicked(); player.closeInventory(); }); // Action when dragging items gui.setDragAction(event -> { event.setCancelled(true); }); // Action when GUI opens gui.setOpenGuiAction(event -> { Player player = (Player) event.getPlayer(); player.sendMessage("Welcome to the menu!"); }); // Action when GUI closes gui.setCloseGuiAction(event -> { Player player = (Player) event.getPlayer(); player.sendMessage("Thanks for visiting!"); }); // Slot-specific action (independent of item) gui.addSlotAction(13, event -> { // This triggers when slot 13 is clicked, regardless of item }); gui.addSlotAction(2, 5, event -> { // Same but using row/column }); // Item-specific action with click type detection GuiItem smartItem = ItemBuilder.from(Material.CHEST) .name(Component.text("Smart Chest")) .asGuiItem(event -> { Player player = (Player) event.getWhoClicked(); ClickType clickType = event.getClick(); if (clickType == ClickType.LEFT) { player.sendMessage("Left click - Open chest"); } else if (clickType == ClickType.RIGHT) { player.sendMessage("Right click - View contents"); } else if (clickType == ClickType.SHIFT_LEFT) { player.sendMessage("Shift+Left - Quick deposit"); } }); gui.setItem(13, smartItem); gui.open(player); ``` -------------------------------- ### Specialized Item Builders for Unique Items Source: https://context7.com/triumphteam/triumph-gui/llms.txt Demonstrates using specialized builders for creating player heads (from texture or OfflinePlayer), custom banners, firework rockets, and map items. ```java import dev.triumphteam.gui.builder.item.ItemBuilder; import org.bukkit.Material; import org.bukkit.DyeColor; import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; // Player head with texture (base64 encoded skin) GuiItem skull = ItemBuilder.skull() .texture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjU2YmM0YmQ...") .name(Component.text("Custom Head")) .asGuiItem(); // Player head from OfflinePlayer OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer("Notch"); GuiItem playerHead = ItemBuilder.skull() .owner(targetPlayer) .name(Component.text("Notch's Head")) .asGuiItem(); // Custom banner GuiItem banner = ItemBuilder.banner() .baseColor(DyeColor.BLUE) .pattern(new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER)) .pattern(new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)) .name(Component.text("Team Banner")) .asGuiItem(); // Firework rocket GuiItem firework = ItemBuilder.firework() .power(2) .asGuiItem(); // Map item GuiItem map = ItemBuilder.map() .name(Component.text("Treasure Map")) .asGuiItem(); ``` -------------------------------- ### Create Scrolling GUIs Source: https://context7.com/triumphteam/triumph-gui/llms.txt Configures vertical or horizontal scrolling interfaces for lists. Requires defining scroll buttons and adding content via the addItem method. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.guis.ScrollingGui; import dev.triumphteam.gui.components.ScrollType; import dev.triumphteam.gui.builder.item.ItemBuilder; import net.kyori.adventure.text.Component; import org.bukkit.Material; // Vertical scrolling GUI (default) ScrollingGui verticalGui = Gui.scrolling(ScrollType.VERTICAL) .title(Component.text("Player List")) .rows(4) .disableAllInteractions() .create(); // Horizontal scrolling GUI ScrollingGui horizontalGui = Gui.scrolling(ScrollType.HORIZONTAL) .title(Component.text("Achievements")) .rows(3) .disableAllInteractions() .create(); // Add border to define scrollable area GuiItem border = ItemBuilder.from(Material.GRAY_STAINED_GLASS_PANE) .name(Component.text(" ")) .asGuiItem(); verticalGui.getFiller().fillBorder(border); // Add scroll buttons GuiItem scrollUp = ItemBuilder.from(Material.ARROW) .name(Component.text("Scroll Up")) .asGuiItem(event -> verticalGui.previous()); GuiItem scrollDown = ItemBuilder.from(Material.ARROW) .name(Component.text("Scroll Down")) .asGuiItem(event -> verticalGui.next()); verticalGui.setItem(0, scrollUp); // Top-left verticalGui.setItem(35, scrollDown); // Bottom-right for 4-row GUI // Add scrollable content for (String playerName : getOnlinePlayers()) { GuiItem playerItem = ItemBuilder.skull() .owner(Bukkit.getOfflinePlayer(playerName)) .name(Component.text(playerName)) .asGuiItem(event -> { // Handle player selection }); verticalGui.addItem(playerItem); } verticalGui.open(player); ``` -------------------------------- ### Perform Dynamic GUI Updates Source: https://context7.com/triumphteam/triumph-gui/llms.txt Update titles, modify specific slots, or refresh entire GUI content at runtime for standard and paginated GUIs. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.guis.PaginatedGui; import dev.triumphteam.gui.builder.item.ItemBuilder; import net.kyori.adventure.text.Component; import org.bukkit.Material; Gui gui = Gui.gui() .title(Component.text("Dynamic Menu")) .rows(3) .disableAllInteractions() .create(); // Update title (re-opens GUI for all viewers) gui.updateTitle(Component.text("New Title!")); // Update specific slot with new ItemStack gui.updateItem(13, new ItemStack(Material.EMERALD, 5)); // Update specific slot with new GuiItem GuiItem newItem = ItemBuilder.from(Material.GOLD_BLOCK) .name(Component.text("Updated Item")) .asGuiItem(); gui.updateItem(13, newItem); // Update using row/column gui.updateItem(2, 5, new ItemStack(Material.DIAMOND)); // Refresh entire GUI (re-populates all items) gui.update(); // For paginated GUIs - update page items PaginatedGui paginatedGui = Gui.paginated() .title(Component.text("Shop")) .rows(6) .create(); // Update item on current page paginatedGui.updatePageItem(10, new ItemStack(Material.DIAMOND, 64)); paginatedGui.updatePageItem(2, 2, newItem); // Row/column version // Clear all page items and refresh paginatedGui.clearPageItems(true); // true = update GUI immediately // Add new items and update paginatedGui.addItem(newItem); paginatedGui.update(); // Remove specific page item paginatedGui.removePageItem(newItem); paginatedGui.removePageItem(new ItemStack(Material.DIAMOND)); ``` -------------------------------- ### Configure GUI Interaction Modifiers Source: https://context7.com/triumphteam/triumph-gui/llms.txt Control player actions like placing, taking, or swapping items within a GUI using the builder or runtime methods. ```java import dev.triumphteam.gui.guis.Gui; import net.kyori.adventure.text.Component; // Configure via builder Gui restrictedGui = Gui.gui() .title(Component.text("Restricted Menu")) .rows(3) .disableItemPlace() // Can't place items from inventory .disableItemTake() // Can't take items from GUI .disableItemSwap() // Can't swap items between slots .disableItemDrop() // Can't drop items while GUI is open .disableOtherActions() // Disables clone/creative actions .create(); // Or disable everything at once Gui fullyLockedGui = Gui.gui() .title(Component.text("Locked Menu")) .rows(3) .disableAllInteractions() .create(); // Modify at runtime fullyLockedGui.enableItemTake(); // Allow taking items fullyLockedGui.disableItemTake(); // Disable again // Check current state boolean canTake = fullyLockedGui.canTakeItems(); boolean canPlace = fullyLockedGui.canPlaceItems(); boolean canSwap = fullyLockedGui.canSwapItems(); boolean canDrop = fullyLockedGui.canDropItems(); boolean allDisabled = fullyLockedGui.allInteractionsDisabled(); // For storage GUIs - allow full interaction Gui storageGui = Gui.storage() .title(Component.text("Player Storage")) .rows(6) .enableAllInteractions() .create(); ``` -------------------------------- ### Positioning Items in Triumph GUI Source: https://context7.com/triumphteam/triumph-gui/llms.txt Use slot numbers or 1-based row/column coordinates to place, remove, or update items within a GUI. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.builder.item.ItemBuilder; import net.kyori.adventure.text.Component; import org.bukkit.Material; Gui gui = Gui.gui() .title(Component.text("Position Demo")) .rows(3) // 27 slots total (0-26) .disableAllInteractions() .create(); GuiItem item = ItemBuilder.from(Material.DIAMOND) .name(Component.text("Diamond")) .asGuiItem(); // Set by slot number (0-based) gui.setItem(0, item); // Top-left corner gui.setItem(8, item); // Top-right corner gui.setItem(13, item); // Center of 3-row GUI // Set by row and column (1-based) gui.setItem(1, 1, item); // Row 1, Column 1 (top-left) = slot 0 gui.setItem(1, 9, item); // Row 1, Column 9 (top-right) = slot 8 gui.setItem(2, 5, item); // Row 2, Column 5 (center) = slot 13 gui.setItem(3, 9, item); // Row 3, Column 9 (bottom-right) = slot 26 // Set same item in multiple slots gui.setItem(Arrays.asList(0, 8, 18, 26), item); // All corners // Remove item from slot gui.removeItem(13); gui.removeItem(2, 5); // Same as removeItem(13) // Update item at slot gui.updateItem(13, new ItemStack(Material.EMERALD)); gui.updateItem(2, 5, new GuiItem(new ItemStack(Material.GOLD_INGOT))); ``` -------------------------------- ### ItemBuilder API for Custom Items Source: https://context7.com/triumphteam/triumph-gui/llms.txt Utilizes the ItemBuilder to create custom Minecraft items with names, lore, enchantments, flags, and glow effects. Also shows creating items with custom model data and colored leather armor. ```java import dev.triumphteam.gui.builder.item.ItemBuilder; import dev.triumphteam.gui.guis.GuiItem; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemFlag; // Basic item with name and lore GuiItem diamondSword = ItemBuilder.from(Material.DIAMOND_SWORD) .name(Component.text("Excalibur", NamedTextColor.GOLD)) .lore( Component.text("A legendary sword", NamedTextColor.GRAY), Component.text(""), Component.text("Damage: +15", NamedTextColor.RED) ) .enchant(Enchantment.SHARPNESS, 5) .enchant(Enchantment.UNBREAKING, 3) .flags(ItemFlag.HIDE_ENCHANTS) .unbreakable() .glow() // Add enchantment glow effect .asGuiItem(event -> { Player player = (Player) event.getWhoClicked(); player.sendMessage("You clicked the sword!"); }); // Item with custom model data (for resource packs) GuiItem customItem = ItemBuilder.from(Material.PAPER) .name(Component.text("Custom Item")) .model(12345) // Custom model data .amount(64) .asGuiItem(); // Colored leather armor GuiItem helmet = ItemBuilder.from(Material.LEATHER_HELMET) .name(Component.text("Red Helmet")) .color(org.bukkit.Color.RED) .asGuiItem(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.