Package tk.airshipcraft.commonlib.gui
Class GuiBuilder
java.lang.Object
tk.airshipcraft.commonlib.gui.GuiBuilder
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
ConstructorsConstructorDescriptionGuiBuilder
(int size, String title) Constructs a new GUI with the specified size and title. -
Method Summary
-
Constructor Details
-
GuiBuilder
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
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.
-