Builder

class Builder(val plugin: ColosseumPlugin)

A builder class for constructing a Gui instance. This class provides a fluent API for defining the structure of the GUI, setting up item bindings and virtual inventory bindings, and configuring other properties of the GUI before building and opening it for a player.

Parameters

plugin

The instance of the ColosseumPlugin

Constructors

Link copied to clipboard
constructor(plugin: ColosseumPlugin)

Types

Link copied to clipboard

An enum representing the direction in which a virtual inventory should be laid out in the GUI.

Properties

Link copied to clipboard

Functions

Link copied to clipboard

Sets whether the GUI can be closed by the player.

Link copied to clipboard

Builds the Gui instance based on the defined structure, item bindings, virtual inventory bindings, and other properties set in the Builder. This method performs validation checks on the structure and bindings to ensure that they are properly defined and do not contain conflicts. If any validation checks fail, an IllegalArgumentException will be thrown with a message indicating the issue. If all checks pass, a new Gui instance will be created and opened for the specified player.

Link copied to clipboard

Binds a character to an AbstractItemProvider. This allows you to use the specified character in the structure of the GUI to indicate where the item provided by the AbstractItemProvider should be displayed. When the GUI is built, any occurrence of the specified character in the structure will be replaced with the item from the AbstractItemProvider.

fun setBinding(char: Char, itemStack: ItemStack): Gui.Builder

A convenience method for binding a character to a SimpleItemProvider that provides a specific ItemStack. This allows you to easily bind a character in the structure to a static item without needing to create a separate AbstractItemProvider class for it. The method creates a new SimpleItemProvider with the provided ItemStack and binds it to the specified character.

fun setBinding(char: Char, virtualInventory: VirtualInventory, marker: Gui.Builder.DirectionMarker = DirectionMarker.HORIZONTAL, id: Int = -1): Gui.Builder

Binds a character to a VirtualInventory. This allows you to use the specified character in the structure of the GUI to indicate where the items from the VirtualInventory should be displayed. When the GUI is built, any occurrence of the specified character in the structure will be associated with the VirtualInventory, and the items from that inventory will be displayed in those slots according to the specified direction (horizontal or vertical). Note that the character ' ' (space) cannot be used for bindings. Additionally, each character can only be bound to one VirtualInventory, so if you try to bind a character that has already been used, an IllegalArgumentException will be thrown.

Link copied to clipboard
fun setPlayer(player: Player): Gui.Builder

Sets the player for whom the GUI will be opened. This is required.

Link copied to clipboard
fun setStructure(vararg strings: String): Gui.Builder

Sets the structure of the GUI using an array of strings. Each string represents a row in the GUI, and each character in the string corresponds to a slot in that row. The characters in the structure should correspond to the characters used in the item bindings and virtual inventory bindings to indicate where those items should be displayed in the GUI. The character ' ' (space) is ignored for clarity.

Link copied to clipboard

Sets the title of the GUI. This is the text that will be displayed at the top of the inventory when the GUI is open. If not set, the default inventory title will be used.