### Configure ShadowJar Plugin for Gradle (Groovy) Source: https://triumphteam.dev/docs/triumph-gui/setup This snippet outlines the setup for the shadowJar plugin in a Groovy Gradle build file, enabling package relocation for the Triumph GUI library. Users must replace '[YOUR PACKAGE]' with their specific plugin package name. ```gradle plugins { id "io.github.goooler.shadow" version "8.1.8" } shadowJar { relocate("dev.triumphteam.gui", "[YOUR PACKAGE].gui") } ``` -------------------------------- ### Create GUI Item - Java Source: https://triumphteam.dev/docs/triumph-gui/gui This example illustrates creating a GuiItem using the ItemBuilder. You can create an item with just a material or add an optional click action that handles the InventoryClickEvent. ```java // Alternatively you can use the ItemBuilder GuiItem guiItem = ItemBuilder.from(Material.STONE).asGuiItem(); GuiItem guiItem = ItemBuilder.from(Material.STONE).asGuiItem(event -> { // Handle your click action here }); ``` -------------------------------- ### Gradle Installation for Triumph GUI (Kotlin DSL) Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt This snippet demonstrates how to include the Triumph GUI library in a Gradle project using the Kotlin DSL. It specifies the Maven Central repository and configures the shadowJar plugin for package relocation. ```kotlin repositories { mavenCentral() } dependencies { implementation("dev.triumphteam:triumph-gui:3.1.7") } plugins { id("io.github.goooler.shadow") version "8.1.8" } shadowJar { relocate("dev.triumphteam.gui", "com.yourplugin.gui") } ``` -------------------------------- ### Gradle Installation for Triumph GUI (Groovy) Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt This snippet shows how to add the Triumph GUI library to a Gradle project using the Groovy DSL. It includes repository configuration and the use of the shadowJar plugin for relocating the library's package. ```groovy repositories { mavenCentral() } dependencies { implementation "dev.triumphteam:triumph-gui:3.1.7" } plugins { id "io.github.goooler.shadow" version "8.1.8" } shadowJar { relocate("dev.triumphteam.gui", "com.yourplugin.gui") } ``` -------------------------------- ### Maven Installation for Triumph GUI Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt This snippet shows how to add the Triumph GUI library as a dependency in a Maven project. It also includes configuration for the Maven Shade Plugin to relocate the library's package, preventing conflicts with other plugins. ```xml dev.triumphteam triumph-gui 3.1.7 org.apache.maven.plugins maven-shade-plugin 3.6.0 dev.triumphteam.gui com.yourplugin.gui package shade ``` -------------------------------- ### Add Slot-Specific Actions in TriumphGUI Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt This example demonstrates how to attach specific actions to GUI slots using TriumphGUI, either by slot index or by row and column. Actions can cancel the event and send messages to the player. Items can be added to these slots, but the actions function independently. Dependencies include TriumphGUI, Adventure API, Bukkit API, and Material enum. ```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; public class SlotActionGUI { public void openGUI(Player player) { Gui gui = Gui.gui() .title(Component.text("Slot Actions")) .rows(3) .create(); // Add action to slot 13 without specifying an item gui.addSlotAction(13, event -> { event.setCancelled(true); player.sendMessage("§eYou clicked slot 13!"); // This works even if the item changes or is removed }); // Add action using row and column (row 2, column 5) gui.addSlotAction(2, 5, event -> { event.setCancelled(true); player.sendMessage("§eYou clicked row 2, column 5!"); }); // Add items to those slots (optional - actions work regardless) gui.setItem(13, ItemBuilder.from(Material.STONE).asGuiItem()); gui.setItem(2, 5, ItemBuilder.from(Material.DIRT).asGuiItem()); gui.open(player); } } ``` -------------------------------- ### Open GUI to Player - Java Source: https://triumphteam.dev/docs/triumph-gui/gui This code demonstrates the simple process of opening a created GUI to a specific player using the open() method. This is the final step to make the GUI visible to the user. ```java gui.open(player); ``` -------------------------------- ### Create and Manage Paginated GUI with TriumphGUI Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt This Java code demonstrates creating a paginated GUI using the TriumphGUI library. It sets up navigation controls (previous/next buttons) and a page indicator, populates the GUI with items, and handles player interactions. The GUI dynamically updates the page indicator when navigating between pages. ```java import dev.triumphteam.gui.guis.PaginatedGui; import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.builder.item.ItemBuilder; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; public class ShopPaginatedGUI { private final Plugin plugin; public ShopPaginatedGUI(Plugin plugin) { this.plugin = plugin; } public void openShop(Player player) { PaginatedGui gui = Gui.paginated() .title(Component.text("Item Shop")) .rows(6) .pageSize(45) .create(); gui.setDefaultClickAction(event -> event.setCancelled(true)); // Navigation with page counter gui.setItem(6, 2, ItemBuilder.from(Material.ARROW) .setName("§e← Previous") .asGuiItem(event -> { event.setCancelled(true); if (gui.getCurrentPageNum() > 0) { gui.previous(); updatePageIndicator(gui); } })); gui.setItem(6, 8, ItemBuilder.from(Material.ARROW) .setName("§eNext →") .asGuiItem(event -> { event.setCancelled(true); if (gui.getCurrentPageNum() < gui.getPagesNum() - 1) { gui.next(); updatePageIndicator(gui); } })); // Page indicator gui.setItem(6, 5, ItemBuilder.from(Material.BOOK) .setName("§6Page " + (gui.getCurrentPageNum() + 1) + "/" + gui.getPagesNum()) .asGuiItem()); // Add 100 items across multiple pages for (int i = 1; i <= 100; i++) { final int itemNumber = i; Material material = Material.values()[i % Material.values().length]; gui.addItem(ItemBuilder.from(material) .setName("§eItem #" + itemNumber) .setLore("§7Price: $" + (itemNumber * 10)) .asGuiItem(event -> { event.setCancelled(true); player.sendMessage("§aPurchased Item #" + itemNumber); })); } gui.open(player); } private void updatePageIndicator(PaginatedGui gui) { gui.updateItem(6, 5, ItemBuilder.from(Material.BOOK) .setName("§6Page " + (gui.getCurrentPageNum() + 1) + "/" + gui.getPagesNum()) .build()); } } ``` -------------------------------- ### Create Paginated GUI - Java Source: https://triumphteam.dev/docs/triumph-gui/pagegui Demonstrates how to instantiate a Paginated GUI. Key parameters include the GUI title, number of rows, and page size. If pageSize is not specified, it will be calculated automatically when the GUI opens. ```java // Main constructor PaginatedGui gui = Gui.paginated() .title(Component.text("GUI Title!")) .rows(6) .pageSize(45) // Set the size you want, or leave it to be automatic. .create(); ``` -------------------------------- ### Using Fillers in GUIs (Java) - TriumphGUI Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt Illustrates how to fill empty slots in a GUI with specified items using TriumphGUI's filler functionality. This includes filling with a single item, multiple alternating items, or clickable items. Requires TriumphGUI and Bukkit API. ```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; public class FilledGUI { public void openGUI(Player player) { Gui gui = Gui.gui() .title(Component.text("Filled Menu")) .rows(3) .create(); // Fill all empty slots with a single item gui.getFiller().fill(ItemBuilder.from(Material.BLACK_STAINED_GLASS_PANE) .setName(" ") .asGuiItem()); // Fill with multiple alternating items gui.getFiller().fill(Arrays.asList( ItemBuilder.from(Material.BLACK_STAINED_GLASS_PANE).setName(" ").asGuiItem(), ItemBuilder.from(Material.WHITE_STAINED_GLASS_PANE).setName(" ").asGuiItem() )); // Fill with clickable items gui.getFiller().fill(ItemBuilder.from(Material.RED_STAINED_GLASS_PANE) .setName(" ") .asGuiItem(event -> { event.setCancelled(true); player.sendMessage("§cYou clicked the border!"); })); gui.open(player); } } ``` -------------------------------- ### Configure ShadowJar Plugin for Gradle (Kotlin) Source: https://triumphteam.dev/docs/triumph-gui/setup This snippet details the configuration for the shadowJar plugin in a Kotlin Gradle build file. It's used to relocate the Triumph GUI package to avoid conflicts with other plugins. Replace '[YOUR PACKAGE]' with your project's package name. ```gradle.kts plugins { id("io.github.goooler.shadow") version "8.1.8" } shadowJar { relocate("dev.triumphteam.gui", "[YOUR PACKAGE].gui") } ``` -------------------------------- ### Add Triumph GUI Dependency for Gradle (Groovy) Source: https://triumphteam.dev/docs/triumph-gui/setup This snippet demonstrates how to include the Triumph GUI library as a dependency in a Groovy Gradle build file. It specifies the mavenCentral() repository and the implementation dependency. The %version% placeholder needs to be replaced with the correct library version. ```gradle repositories { mavenCentral() } dependencies { implementation "dev.triumphteam:triumph-gui:%version%" } ``` -------------------------------- ### Add Triumph GUI Dependency for Gradle (Kotlin) Source: https://triumphteam.dev/docs/triumph-gui/setup This snippet shows how to add the Triumph GUI library as a dependency in a Kotlin Gradle build file. It requires the mavenCentral() repository and specifies the implementation dependency. The %version% placeholder should be replaced with the actual library version. ```gradle.kts repositories { mavenCentral() } dependencies { implementation("dev.triumphteam:triumph-gui:%version%") } ``` -------------------------------- ### Create Basic GUI - Java Source: https://triumphteam.dev/docs/triumph-gui/gui This snippet demonstrates how to create a basic GUI with a specified title and number of rows. The default GUI type is CHEST. Dependencies include the Gui, Component, and Gui.gui() methods. ```java Gui gui = Gui.gui() .title(Component.text("GUI Title!")) .rows(6) .create(); ``` -------------------------------- ### Create a Standard Chest GUI with Triumph GUI (Java) Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt This Java code snippet demonstrates the creation of a basic chest GUI using the Triumph GUI library. It shows how to set the GUI title, rows, create custom items with click actions, add items to specific slots or the next available slot, and open the GUI for a player. Dependencies include Bukkit/Spigot API and Kyori Adventure. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.builder.item.ItemBuilder; import dev.triumphteam.gui.guis.GuiItem; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Player; public class ShopGUI { public void openShop(Player player) { // Create a 6-row chest GUI Gui gui = Gui.gui() .title(Component.text("Item Shop")) .rows(6) .create(); // Create a GUI item with click action GuiItem diamondItem = ItemBuilder.from(Material.DIAMOND) .setName("§bDiamond - $100") .setLore("§7Click to purchase", "§7Stock: 64") .asGuiItem(event -> { event.setCancelled(true); Player clicker = (Player) event.getWhoClicked(); clicker.sendMessage("§aYou purchased a diamond!"); // Add your purchase logic here }); // Add item at slot 13 (center of top row) gui.setItem(13, diamondItem); // Add item at row 2, column 5 GuiItem goldItem = ItemBuilder.from(Material.GOLD_INGOT) .setName("§6Gold Ingot - $50") .asGuiItem(event -> { event.setCancelled(true); ((Player) event.getWhoClicked()).sendMessage("§aYou purchased gold!"); }); gui.setItem(2, 5, goldItem); // Add items to next available slots for (int i = 0; i < 5; i++) { GuiItem emerald = ItemBuilder.from(Material.EMERALD) .setName("§2Emerald - $75") .asGuiItem(event -> event.setCancelled(true)); gui.addItem(emerald); } // Open GUI for player gui.open(player); } } ``` -------------------------------- ### Create Typed GUIs (Java) - TriumphGUI Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt Demonstrates creating different types of GUIs such as Dispenser, Hopper, and Workbench using TriumphGUI. This involves setting the GUI type and adding items with specific click actions. It requires the TriumphGUI library and Bukkit API. ```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; public class CraftingMenu { public void openCraftingMenu(Player player) { // Create a dispenser-type GUI (9 slots) Gui gui = Gui.gui() .title(Component.text("Quick Crafting")) .type(GuiType.DISPENSER) .create(); // Add crafting recipes to dispenser slots (0-8) gui.setItem(0, ItemBuilder.from(Material.CRAFTING_TABLE) .setName("§eCrafting Table") .asGuiItem(event -> { event.setCancelled(true); player.openWorkbench(null, true); })); gui.setItem(1, ItemBuilder.from(Material.FURNACE) .setName("§6Furnace") .asGuiItem(event -> { event.setCancelled(true); // Open furnace logic })); // Hopper GUI (5 slots: 0-4) Gui hopperGui = Gui.gui() .title(Component.text("Hopper Menu")) .type(GuiType.HOPPER) .create(); // Workbench GUI (10 slots: 0-9) Gui workbenchGui = Gui.gui() .title(Component.text("Crafting")) .type(GuiType.WORKBENCH) .create(); gui.open(player); } } ``` -------------------------------- ### Create and Navigate Paginated GUI (Java) Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt This snippet shows how to create a paginated GUI with custom navigation buttons and player items. It uses the TriumphGUI library to manage pagination and item interactions. Dependencies include TriumphGUI, Adventure API, and Bukkit API. ```java import dev.triumphteam.gui.guis.PaginatedGui; 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 java.util.List; public class PlayerListGUI { public void openPlayerList(Player viewer, List allPlayers) { // Create paginated GUI with 45 item slots per page PaginatedGui gui = Gui.paginated() .title(Component.text("Online Players")) .rows(6) .pageSize(45) // Slots dedicated to paginated items .create(); // Set default click action to cancel all clicks gui.setDefaultClickAction(event -> event.setCancelled(true)); // Add navigation buttons (these are static, not paginated) gui.setItem(6, 3, ItemBuilder.from(Material.PAPER) .setName("§e← Previous Page") .asGuiItem(event -> { event.setCancelled(true); gui.previous(); })); gui.setItem(6, 7, ItemBuilder.from(Material.PAPER) .setName("§eNext Page →") .asGuiItem(event -> { event.setCancelled(true); gui.next(); })); // Add page indicator gui.setItem(6, 5, ItemBuilder.from(Material.COMPASS) .setName("§6Page Info") .setLore("§7Current: " + (gui.getCurrentPageNum() + 1), "§7Total: " + gui.getPagesNum()) .asGuiItem()); // Add all players to paginated items for (Player p : allPlayers) { gui.addItem(ItemBuilder.from(Material.PLAYER_HEAD) .setName("§b" + p.getName()) .setLore( "§7Health: " + p.getHealth() + "/20", "§7Location: " + p.getLocation().getBlockX() + ", " + p.getLocation().getBlockY() + ", " + p.getLocation().getBlockZ(), "§aClick to teleport" ) .asGuiItem(event -> { event.setCancelled(true); viewer.teleport(p); viewer.sendMessage("§aTeleported to " + p.getName()); })); } // Fill empty slots with glass pane gui.getFiller().fill(ItemBuilder.from(Material.GRAY_STAINED_GLASS_PANE) .setName(" ") .asGuiItem()); gui.open(viewer); } } ``` -------------------------------- ### Setting Default Click Action in GUIs (Java) - TriumphGUI Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt Shows how to set a default click action for all items within a GUI using TriumphGUI. This action is executed before any specific item's click action. Requires TriumphGUI and Bukkit API. ```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; public class DefaultActionGUI { public void openGUI(Player player) { Gui gui = Gui.gui() .title(Component.text("Default Action Menu")) .rows(3) .create(); // Set default action for ALL slots gui.setDefaultClickAction(event -> { event.setCancelled(true); // Cancel all clicks by default Player clicker = (Player) event.getWhoClicked(); clicker.sendMessage("§7This action applies to all items!"); }); // Add items - they inherit the default action plus any specific actions gui.setItem(13, ItemBuilder.from(Material.DIAMOND) .setName("§bDiamond") .asGuiItem(event -> { // This runs AFTER the default action player.sendMessage("§aYou clicked the diamond!"); })); gui.setItem(14, ItemBuilder.from(Material.EMERALD) .setName("§2Emerald") .asGuiItem()); gui.open(player); } } ``` -------------------------------- ### Add Triumph GUI Dependency for Maven Source: https://triumphteam.dev/docs/triumph-gui/setup This snippet shows the Maven dependency configuration required to include the Triumph GUI library in your project's pom.xml. It specifies the groupId, artifactId, and version. The %version% placeholder should be updated with the actual library version. ```xml dev.triumphteam triumph-gui %version% ``` -------------------------------- ### Create Storage GUI Source: https://triumphteam.dev/docs/triumph-gui/storagegui Demonstrates how to create a persistent Storage GUI with a specified title and number of rows. This GUI retains its items even when closed and reopened, but not across server restarts. ```java StorageGui gui = Gui.storage() .title(Component.text("GUI Title!")) .rows(6) .create(); ``` -------------------------------- ### Handle GUI Open and Close Events with TriumphGUI Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt This snippet shows how to set actions for when a GUI is opened or closed using TriumphGUI. It includes handling player messages upon opening and closing, and checking the reason for the inventory close event. Dependencies include TriumphGUI, Adventure API for text components, and Bukkit API for player and events. ```java import dev.triumphteam.gui.guis.Gui; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryOpenEvent; public class EventHandlingGUI { public void openGUI(Player player) { Gui gui = Gui.gui() .title(Component.text("Event Tracking")) .rows(3) .create(); // Handle GUI open event gui.setOpenGuiAction(event -> { Player opener = (Player) event.getPlayer(); opener.sendMessage("§aWelcome to the menu!"); // Log analytics, play sound, etc. }); // Handle GUI close event gui.setCloseGuiAction(event -> { Player closer = (Player) event.getPlayer(); closer.sendMessage("§7Thanks for using the menu!"); // Save player data, clean up resources, etc. // Check close reason if (event.getReason() == InventoryCloseEvent.Reason.PLAYER) { closer.sendMessage("§7You closed the menu manually."); } }); gui.open(player); } } ``` -------------------------------- ### Create Persistent Storage GUI with Triumph GUI Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt Shows how to create a persistent storage GUI using `StorageGui`. This type of GUI allows players to store items that will remain even after the GUI is closed and reopened. It's suitable for player vaults or persistent inventories. ```java import dev.triumphteam.gui.guis.StorageGui; 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.inventory.ItemStack; public class PlayerVaultGUI { public void openVault(Player player) { // Create storage GUI that persists player-added items StorageGui gui = Gui.storage() .title(Component.text("Personal Vault")) .rows(6) .create(); // Set default click action gui.setDefaultClickAction(event -> { // Allow normal inventory interactions for StorageGui // Items placed by players will persist between opens/closes }); // Add static GuiItems (with click actions) gui.setItem(53, ItemBuilder.from(Material.BARRIER) .setName("§cClose") .asGuiItem(event -> { event.setCancelled(true); player.closeInventory(); })); gui.setItem(52, ItemBuilder.from(Material.CHEST) .setName("§eSave Vault") .asGuiItem(event -> { event.setCancelled(true); player.sendMessage("§aVault saved!"); // Save vault contents to database })); // Add regular ItemStacks (no click actions, player can interact freely) gui.addItem(new ItemStack(Material.STONE, 64)); gui.addItem(new ItemStack(Material.DIAMOND, 16)); // Open GUI - items persist between sessions gui.open(player); } } ``` -------------------------------- ### Create Filtered Storage GUI with Java Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt Demonstrates how to create a storage GUI that restricts items to only ores. It utilizes `StorageGui` for item management and custom click actions to enforce restrictions. Dependencies include Triumph GUI, Adventure API, and Bukkit API. ```java import dev.triumphteam.gui.guis.StorageGui; 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.InventoryClickEvent; import org.bukkit.inventory.ItemStack; public class FilteredStorageGUI { public void openFilteredStorage(Player player) { StorageGui gui = Gui.storage() .title(Component.text("Ore Storage")) .rows(6) .create(); // Custom click handler to filter items gui.setDefaultClickAction(event -> { ItemStack cursor = event.getCursor(); ItemStack current = event.getCurrentItem(); // Only allow ore-type items if (cursor != null && !isOreItem(cursor.getType())) { event.setCancelled(true); player.sendMessage("§cOnly ores can be stored here!"); return; } // Allow normal storage interactions for valid items }); // Add existing items gui.addItem(new ItemStack(Material.DIAMOND_ORE, 32)); gui.addItem(new ItemStack(Material.IRON_ORE, 64)); gui.addItem(new ItemStack(Material.GOLD_ORE, 48)); // Add close button gui.setItem(53, ItemBuilder.from(Material.BARRIER) .setName("§cClose") .asGuiItem(event -> { event.setCancelled(true); player.closeInventory(); })); // Handle close event to save contents gui.setCloseGuiAction(event -> { Player closer = (Player) event.getPlayer(); // Save storage contents to player data saveStorageContents(closer, gui); }); gui.open(player); } private boolean isOreItem(Material material) { String name = material.name(); return name.contains("_ORE") || name.contains("RAW_"); } private void saveStorageContents(Player player, StorageGui gui) { // Implementation to save GUI contents to database/file player.sendMessage("§aStorage contents saved!"); } } ``` -------------------------------- ### Configure Maven Shade Plugin for Package Relocation Source: https://triumphteam.dev/docs/triumph-gui/setup This snippet details the Maven Shade plugin configuration in pom.xml for relocating the Triumph GUI package. This is crucial for preventing package conflicts. Ensure to replace '[YOUR PACKAGE]' with your project's package name in the shadedPattern. ```xml org.apache.maven.plugins maven-shade-plugin 3.6.0 dev.triumphteam.gui [YOUR PACKAGE].gui package shade ``` -------------------------------- ### Create Typed GUI - Java Source: https://triumphteam.dev/docs/triumph-gui/gui This code shows how to create a GUI with a specific type, such as DISPENSER, HOPPER, or WORKBENCH. If no type is specified, it defaults to GuiType.CHEST. Supported types include CHEST, WORKBENCH, HOPPER, DISPENSER, and BREWING. ```java Gui gui = Gui.gui() .title(Component.text("GUI Title!")) .type(GuiType.DISPENSER) .create(); ``` -------------------------------- ### Paginated GUI Navigation - Java Source: https://triumphteam.dev/docs/triumph-gui/pagegui Shows how to add navigation items (Previous and Next buttons) to a Paginated GUI. These items are placed at specific slots and trigger the `previous()` and `next()` methods of the PaginatedGui instance upon clicking. ```java // Previous item paginatedGui.setItem(6, 3, ItemBuilder.from(Material.PAPER).setName("Previous").asGuiItem(event -> paginatedGui.previous())); // Next item paginatedGui.setItem(6, 7, ItemBuilder.from(Material.PAPER).setName("Next").asGuiItem(event -> paginatedGui.next())); ``` -------------------------------- ### Create Vertical Scrolling GUI with TriumphGUI Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt This Java code snippet shows how to initialize a vertical scrolling GUI using TriumphGUI. It sets the title, size, and scroll type, and configures default click actions and navigation buttons. It also demonstrates adding items with dynamic properties and click events. Dependencies include TriumphGUI, Adventure API, and Bukkit API. ```java import dev.triumphteam.gui.guis.ScrollingGui; import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.guis.ScrollType; import dev.triumphteam.gui.builder.item.ItemBuilder; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Player; import java.util.List; public class QuestLogGUI { public void openQuestLog(Player player, List quests) { // Create scrolling GUI with vertical scroll ScrollingGui gui = Gui.scrolling() .title(Component.text("Quest Log")) .rows(6) .pageSize(45) .scrollType(ScrollType.VERTICAL) .create(); gui.setDefaultClickAction(event -> event.setCancelled(true)); // Scroll navigation gui.setItem(6, 3, ItemBuilder.from(Material.ARROW) .setName("§e↑ Scroll Up") .asGuiItem(event -> { event.setCancelled(true); gui.previous(); // Scrolls up one row })); gui.setItem(6, 7, ItemBuilder.from(Material.ARROW) .setName("§e↓ Scroll Down") .asGuiItem(event -> { event.setCancelled(true); gui.next(); // Scrolls down one row })); // Add quest items for (Quest quest : quests) { gui.addItem(ItemBuilder.from(quest.isCompleted() ? Material.LIME_STAINED_GLASS_PANE : Material.PAPER) .setName(quest.isCompleted() ? "§a✓ " + quest.getName() : "§e" + quest.getName()) .setLore( "§7" + quest.getDescription(), "§7Progress: " + quest.getProgress() + "/" + quest.getMaxProgress(), quest.isCompleted() ? "§a§lCOMPLETED" : "§e§lIN PROGRESS" ) .asGuiItem(event -> { event.setCancelled(true); player.sendMessage("§6Quest: §f" + quest.getName()); player.sendMessage("§7" + quest.getDescription()); })); } gui.open(player); } // Example Quest class private static class Quest { private final String name; private final String description; private final int progress; private final int maxProgress; public Quest(String name, String description, int progress, int maxProgress) { this.name = name; this.description = description; this.progress = progress; this.maxProgress = maxProgress; } public String getName() { return name; } public String getDescription() { return description; } public int getProgress() { return progress; } public int getMaxProgress() { return maxProgress; } public boolean isCompleted() { return progress >= maxProgress; } } } ``` -------------------------------- ### Fill GUI Slots with Items Source: https://triumphteam.dev/docs/triumph-gui/features Allows filling empty slots in a GUI with specified items. Supports filling with a single item or multiple items, and these fill items can have a default click action applied to all filled slots. ```java // Single fill item gui.getFiller().fill(ItemBuilder.from(Material.BLACK_STAINED_GLASS_PANE).asGuiItem()); // Multiple fill items gui.getFiller().fill(Arrays.asList(ItemBuilder.from(Material.BLACK_STAINED_GLASS_PANE).asGuiItem(), ItemBuilder.from(Material.WHITE_STAINED_GLASS_PANE).asGuiItem())); ``` -------------------------------- ### Build Custom Items with Java Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt Shows how to create custom `ItemStack` objects with various properties like names, lore, enchantments, flags, glow, and durability using the `ItemBuilder` class. This is useful for creating unique game items. Dependencies include Triumph GUI and Bukkit API. ```java import dev.triumphteam.gui.builder.item.ItemBuilder; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; public class ItemCreation { public ItemStack createCustomSword() { return ItemBuilder.from(Material.DIAMOND_SWORD) .setName("§c§lLegendary Blade") .setLore( "§7A powerful weapon forged", "§7in the depths of the Nether.", "", "§c+50 Attack Damage", "§9+10 Magic Power" ) .addEnchant(Enchantment.DAMAGE_ALL, 5, true) .addEnchant(Enchantment.FIRE_ASPECT, 2, true) .setFlags(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_ATTRIBUTES) .setGlow(true) .build(); } public ItemStack createPlayerHead(String playerName) { return ItemBuilder.skull() .setOwner(playerName) .setName("§b" + playerName + "'s Head") .setLore("§7A trophy of victory!") .build(); } public ItemStack createUnbreakableTool() { return ItemBuilder.from(Material.DIAMOND_PICKAXE) .setName("§e§lEternal Pickaxe") .setLore("§7This tool will never break!") .setUnbreakable(true) .setFlags(ItemFlag.HIDE_UNBREAKABLE) .build(); } public ItemStack createCustomAmount() { return ItemBuilder.from(Material.GOLD_INGOT) .setAmount(16) .setName("§6Gold Stack") .build(); } } ``` -------------------------------- ### Update GUI Content Dynamically with TriumphGUI Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt This code illustrates how to dynamically update GUI elements using TriumphGUI, including individual items and the GUI title. Updates can be scheduled using Bukkit's scheduler. The `update()` method refreshes the entire GUI, while `updateItem()` is more efficient for single item changes. Dependencies include TriumphGUI, Adventure API, Bukkit API, and ItemStack. ```java import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.builder.item.ItemBuilder; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.inventory.ItemStack; public class DynamicGUI { private final Plugin plugin; public DynamicGUI(Plugin plugin) { this.plugin = plugin; } public void openGUI(Player player) { Gui gui = Gui.gui() .title(Component.text("Dynamic Menu")) .rows(3) .create(); // Add a counter item gui.setItem(13, ItemBuilder.from(Material.CLOCK) .setName("§eCounter: 0") .asGuiItem()); // Update entire GUI (except title) Bukkit.getScheduler().runTaskLater(plugin, () -> { gui.setItem(13, ItemBuilder.from(Material.CLOCK) .setName("§eCounter: 1") .asGuiItem()); gui.update(); // Refreshes all items }, 20L); // Update specific item only (preferred method) Bukkit.getScheduler().runTaskLater(plugin, () -> { ItemStack newItem = ItemBuilder.from(Material.CLOCK) .setName("§eCounter: 2") .build(); gui.updateItem(13, newItem); // Only updates slot 13 }, 40L); // Update using row and column Bukkit.getScheduler().runTaskLater(plugin, () -> { ItemStack newItem = ItemBuilder.from(Material.CLOCK) .setName("§eCounter: 3") .build(); gui.updateItem(2, 5, newItem); // Row 2, Column 5 }, 60L); // Update title (experimental feature) Bukkit.getScheduler().runTaskLater(plugin, () -> { gui.updateTitle(Component.text("Updated Title!")); }, 80L); gui.open(player); } } ``` -------------------------------- ### Create Horizontal Scrolling GUI with Triumph GUI Source: https://context7.com/context7/triumphteam_dev_triumph-gui/llms.txt Demonstrates the creation of a horizontal scrolling GUI for an image gallery. It utilizes `ScrollingGui` with `ScrollType.HORIZONTAL` to allow navigation through items using arrow buttons. Items added to the GUI persist within the scrollable area. ```java import dev.triumphteam.gui.guis.ScrollingGui; import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.guis.ScrollType; import dev.triumphteam.gui.builder.item.ItemBuilder; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Player; public class ImageGalleryGUI { public void openGallery(Player player) { // Create horizontal scrolling GUI ScrollingGui gui = Gui.scrolling() .title(Component.text("Image Gallery")) .rows(3) .pageSize(21) // 3 rows × 7 columns .scrollType(ScrollType.HORIZONTAL) .create(); gui.setDefaultClickAction(event -> event.setCancelled(true)); // Horizontal scroll navigation gui.setItem(2, 1, ItemBuilder.from(Material.ARROW) .setName("§e← Scroll Left") .asGuiItem(event -> { event.setCancelled(true); gui.previous(); })); gui.setItem(2, 9, ItemBuilder.from(Material.ARROW) .setName("§eScroll Right →") .asGuiItem(event -> { event.setCancelled(true); gui.next(); })); // Add 50 "images" (different colored blocks) Material[] colors = { Material.WHITE_WOOL, Material.ORANGE_WOOL, Material.MAGENTA_WOOL, Material.LIGHT_BLUE_WOOL, Material.YELLOW_WOOL, Material.LIME_WOOL, Material.PINK_WOOL, Material.GRAY_WOOL, Material.LIGHT_GRAY_WOOL, Material.CYAN_WOOL, Material.PURPLE_WOOL, Material.BLUE_WOOL, Material.BROWN_WOOL, Material.GREEN_WOOL, Material.RED_WOOL, Material.BLACK_WOOL }; for (int i = 0; i < 50; i++) { final int imageNum = i + 1; Material color = colors[i % colors.length]; gui.addItem(ItemBuilder.from(color) .setName("§eImage #" + imageNum) .setLore("§7Click to view fullscreen") .asGuiItem(event -> { event.setCancelled(true); player.sendMessage("§aViewing Image #" + imageNum); })); } gui.open(player); } } ``` -------------------------------- ### Set GUI Open Action Source: https://triumphteam.dev/docs/triumph-gui/features Defines an action to be executed whenever the GUI is opened. The `InventoryOpenEvent` is passed to the action handler. ```java gui.setOpenGuiAction(event -> { // Handle your open action }); ``` -------------------------------- ### Create a Scrolling GUI - Java Source: https://triumphteam.dev/docs/triumph-gui/scrollgui This snippet demonstrates how to instantiate a Scrolling GUI. It allows customization of the GUI title, number of rows, page size, and scroll orientation (vertical or horizontal). If scrollType is not specified, it defaults to VERTICAL. The configuration is similar to Paginated GUI, with specific parameters for rows and page size. ```java ScrollingGui gui = Gui.scrolling() .title(Component.text("GUI Title!")) .rows(6) .pageSize(45) .scrollType(ScrollType.HORIZONTAL) .create(); ``` -------------------------------- ### Add Item to GUI - Java Source: https://triumphteam.dev/docs/triumph-gui/gui This snippet shows various ways to add a GuiItem to a GUI: by specifying a slot number (0-53), by using row and column coordinates, or by adding to the next available slot using addItem(). Exceeding the GUI limit will throw a GuiException. ```java // Using a slot number from 0 to 53 gui.setItem(slot, guiItem); // Using rows and columns gui.setItem(row, col, guiItem); // Using add item to add to next free slot gui.addItem(guiItem); ``` -------------------------------- ### Update Entire GUI Source: https://triumphteam.dev/docs/triumph-gui/features Refreshes the entire GUI. Note that this method does not update the GUI's title due to inventory system limitations. ```java gui.update(); ``` -------------------------------- ### Set Default Click Action for GUI Source: https://triumphteam.dev/docs/triumph-gui/features Sets a default click action that will be applied to every single slot in the GUI. This is useful for global actions like cancelling events for all items. ```java gui.setDefaultClickAction(event -> { // Handle your default action here }); ``` -------------------------------- ### Add Slot-Specific Click Actions Source: https://triumphteam.dev/docs/triumph-gui/features Allows adding a click action to a specific slot, row, or column without needing to place an item in that slot. This is useful for interactive elements that don't require a visual item. ```java // With slot gui.addSlotAction(slot, event -> { // Handle your open action }); // With rows and columns gui.addSlotAction(row, col, event -> { // Handle your open action }); ``` -------------------------------- ### Update GUI Title Source: https://triumphteam.dev/docs/triumph-gui/features Updates the title of the GUI. This method requires passing the new title as a `Component` object. It is noted that this feature may require further testing. ```java gui.updateTitle(Component.text("New Title")); ``` -------------------------------- ### Update Specific GUI Item Source: https://triumphteam.dev/docs/triumph-gui/features Updates a single item within the GUI, identified by its slot, row, or column. This is the recommended method for making changes to individual items, especially for dynamic or refreshing elements, as it is more efficient than updating the entire GUI. ```java // Using slots gui.updateItem(slot, new ItemStack(Material.STONE)); // Using rows and columns gui.updateItem(row, col, new ItemStack(Material.STONE)); ``` -------------------------------- ### Set GUI Close Action Source: https://triumphteam.dev/docs/triumph-gui/features Defines an action to be executed whenever the GUI is closed. The `InventoryCloseEvent` is passed to the action handler. ```java gui.setCloseGuiAction(event -> { // Handle your close action }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.