triumph-gui Documentation

repository·master·Indexed 19 days ago

https://github.com/triumphteam/triumph-gui

A Java library available via Maven Central designed to simplify the creation of Graphical User Interfaces (GUIs). It features the GuiContainer interface for managing GUI structures, including Chest-based containers with row-based sizing and Typed containers based on specific GuiType definitions.

Tokens
722
Snippets
4
Records
5
Agent score
16%

What's inside triumph-gui

  1. Install triumph-gui via Maven

    master

    You can include triumph-gui in your Java project by using the Maven dependency coordinates. The artifact is hosted on Maven Central under the group ID dev.triumphteam.

    <!-- Reference to Maven Central -->
    https://search.maven.org/artifact/dev.triumphteam/triumph-gui
  2. Use the GuiContainer interface to manage GUI structures

    master

    The GuiContainer interface defines the blueprint for creating and managing GUI inventories (such as Chests or Typed inventories) in the Triumph-GUI library. It provides methods to manage the display title, determine the inventory size and row count, and identify the GuiType. To actually instantiate a Bukkit Inventory, you use the createInventory(InventoryHolder inventoryHolder) method, which relies on an underlying InventoryProvider implementation.

    // Conceptual usage of a GuiContainer
    GuiContainer container = ...;
    Inventory inventory = container.createInventory(player);
  3. Implement a Typed GUI container

    master

    The Typed implementation of GuiContainer allows for creating inventories based on a specific GuiType. Unlike the Chest implementation which uses rows to determine size, the Typed container uses the GuiType to determine both the inventory size (via guiType.getLimit()) and the specific inventory type (via guiType.getInventoryType()).

    // Example of creating a Typed container
    GuiContainer typed = new GuiContainer.Typed(
        Component.text("Typed GUI"),
        typedInventoryProvider, // An implementation of InventoryProvider.Typed
        GuiType.PLAYER_HEAD // A specific GuiType
    );
  4. Implement a Chest-based GUI container

    master

    The Chest implementation of GuiContainer represents a standard chest-style inventory. It is defined by a title, a specific number of rows, and an InventoryProvider.Chest to handle the actual inventory creation. The inventory size is automatically calculated as rows * 9.

    // Example of creating a Chest container
    GuiContainer chest = new GuiContainer.Chest(
        Component.text("My Chest GUI"),
        chestInventoryProvider, // An implementation of InventoryProvider.Chest
        3 // Number of rows
    );