Class GuiBuilder

java.lang.Object
tk.airshipcraft.commonlib.gui.GuiBuilder

public class GuiBuilder extends Object
A class to build and manage Graphical User Interfaces (GUIs) in Minecraft. This builder class facilitates the creation of custom inventory interfaces by providing a fluent interface for adding items and setting properties. It encapsulates the complexity of managing inventory slots and item placement, streamlining the process of GUI creation.
Since:
2023-11-20
Version:
1.0.0
Author:
notzune
  • Constructor Summary

    Constructors
    Constructor
    Description
    GuiBuilder(int size, String title)
    Constructs a new GUI with the specified size and title.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.inventory.Inventory
    Finalizes the GUI construction and retrieves the built Inventory instance.
    setItem(int slot, org.bukkit.inventory.ItemStack item)
    Adds an item to the GUI at the specified slot.

    Methods inherited from class java.lang.Object

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

    • GuiBuilder

      public GuiBuilder(int size, String title)
      Constructs a new GUI with the specified size and title. The size must be a multiple of 9 as it corresponds to the number of slots in a single inventory row.
      Parameters:
      size - The number of slots in the inventory (must be a multiple of 9).
      title - The title displayed at the top of the inventory GUI.
  • Method Details

    • setItem

      public GuiBuilder setItem(int slot, org.bukkit.inventory.ItemStack item)
      Adds an item to the GUI at the specified slot. This method is designed for chaining, allowing multiple calls to be linked in a single line of code for convenient GUI setup.
      Parameters:
      slot - The slot index where the item should be placed.
      item - The ItemStack to be placed at the specified slot.
      Returns:
      The current instance of GuiBuilder, for chaining method calls.
    • build

      public org.bukkit.inventory.Inventory build()
      Finalizes the GUI construction and retrieves the built Inventory instance. This method should be called once all desired items and properties have been set.
      Returns:
      The completed Inventory object representing the GUI.