java.lang.Object
tk.airshipcraft.commonlib.gui.objects.Ui

public class Ui extends Object
Represents a custom User Interface (UI) in Minecraft, facilitating the creation and management of custom inventory interfaces. This class allows for the design and interaction of inventory-based GUIs such as chests or hoppers, with custom layouts and functionalities. It supports adding items as buttons and managing these interfaces within the Minecraft environment.
Since:
2023-11-20
Version:
1.0.0
Author:
Locutusque, notzune
  • Constructor Summary

    Constructors
    Constructor
    Description
    Ui(String inventoryName, org.bukkit.inventory.InventoryHolder owner, org.bukkit.event.inventory.InventoryType type, int rows)
    Constructs a new Ui instance with specified parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addButton(org.bukkit.inventory.ItemStack item, int slot)
    Adds an item as a button to the UI at the specified slot.
    org.bukkit.inventory.Inventory
    Obtains the Inventory object representing this UI.
    Gets the unique identifier of this UI instance.
    Retrieves the name of the UI's inventory.
    org.bukkit.inventory.InventoryHolder
    Retrieves the InventoryHolder associated with this UI.
    int
    Retrieves the number of rows in the UI's inventory.
    org.bukkit.event.inventory.InventoryType
    Gets the type of the UI's inventory.
    static boolean
    isUi(org.bukkit.inventory.Inventory inventory)
    Checks if a given inventory is a custom UI created by this class.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Ui

      public Ui(String inventoryName, org.bukkit.inventory.InventoryHolder owner, org.bukkit.event.inventory.InventoryType type, int rows)
      Constructs a new Ui instance with specified parameters. This constructor sets up a custom inventory interface, which can be a chest, hopper, etc., based on the provided type and rows.
      Parameters:
      inventoryName - The name of the inventory, displayed at the top of the UI.
      owner - The InventoryHolder associated with this UI, can be null.
      type - The type of inventory (e.g., CHEST, HOPPER) to create.
      rows - The number of rows in the inventory if it's a chest type.
  • Method Details

    • isUi

      public static boolean isUi(org.bukkit.inventory.Inventory inventory)
      Checks if a given inventory is a custom UI created by this class. This static method can be used to verify if an inventory is part of the custom UI system.
      Parameters:
      inventory - The Inventory to check.
      Returns:
      True if the inventory is a custom UI created by this class, false otherwise.
    • addButton

      public void addButton(org.bukkit.inventory.ItemStack item, int slot)
      Adds an item as a button to the UI at the specified slot. This method places an ItemStack in the inventory at a given slot, which can represent a button or an interactive element.
      Parameters:
      item - The ItemStack to be added as a button.
      slot - The inventory slot where the item will be placed.
    • getInventoryName

      public String getInventoryName()
      Retrieves the name of the UI's inventory.
      Returns:
      The name of the inventory.
    • getInventoryId

      public UUID getInventoryId()
      Gets the unique identifier of this UI instance. This UUID can be used to distinguish and track individual UIs.
      Returns:
      The UUID of the inventory.
    • getOwner

      public org.bukkit.inventory.InventoryHolder getOwner()
      Retrieves the InventoryHolder associated with this UI. The InventoryHolder represents the entity or object that holds this UI.
      Returns:
      The InventoryHolder of this UI, which may be null.
    • getInventory

      public org.bukkit.inventory.Inventory getInventory()
      Obtains the Inventory object representing this UI. This inventory is the actual container in which items and buttons are placed.
      Returns:
      The Inventory instance representing this UI.
    • getType

      public org.bukkit.event.inventory.InventoryType getType()
      Gets the type of the UI's inventory. The type determines the layout and behavior of the inventory (e.g., chest, hopper).
      Returns:
      The InventoryType of this UI.
    • getRows

      public int getRows()
      Retrieves the number of rows in the UI's inventory. This is relevant for types like chests that have a variable number of rows.
      Returns:
      The number of rows in the inventory.