PaginatedDynamicGUI

class PaginatedDynamicGUI<S : Enum<S>>(enumClass: Class<S>, player: Player) : InventoryGUI

A generic class used to create a paginated GUI in Minecraft, allowing dynamic switching between pages and states mapped to an enum type. It supports custom item mappings, navigation buttons, and empty state messages to provide a flexible inventory GUI system.

Parameters

S

the enum type for state management must extend Enum

enumClass

the class of the enum used for managing GUI states

player

the player associated with the GUI

Constructors

Link copied to clipboard
constructor(enumKClass: KClass<S>, player: Player)

Constructs a PaginatedDynamicGUI instance by delegating the given enumKClass and player to another constructor.

constructor(enumClass: Class<S>, player: Player)

Types

Link copied to clipboard
object Companion

A companion object for the PaginatedDynamicGUI class. Provides a utility function to create an instance of the PaginatedDynamicGUI for a given Enum class and player.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Represents the list of buttons to be displayed in this inventory GUI. Each button corresponds to a slot and can define its own material, name, custom data, and click behavior.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Adds a single item to the existing item list.

Link copied to clipboard
open override fun build(): InventoryGUI

Constructs and prepares the InventoryGUI object for use by setting the appropriate state and displaying it. If the currentState is null and the enumClass corresponds to SinglePage, it initializes currentState with SinglePage.PAGE.

Link copied to clipboard
fun close()

Closes the inventory for the player.

Link copied to clipboard
open override fun getAllButtons(): List<Button>
Link copied to clipboard
fun getBackgroundMaterial(): Material?

Gets the background material set for the inventory GUI.

Link copied to clipboard
open override fun getInventory(): Inventory

Returns the inventory associated with this GUI.

Link copied to clipboard

Gets the current listener associated with this GUI.

Link copied to clipboard
fun getSize(): Int?

Gets the size of the inventory GUI.

Link copied to clipboard
fun getTitle(): Component?

Gets the title of this GUI.

Link copied to clipboard
fun nextPage()
Link copied to clipboard

Sets a handler to be called when this GUI is closed.

Link copied to clipboard
fun open()

Opens the inventory for the player.

Link copied to clipboard
fun prevPage()
Link copied to clipboard
fun setBackground(background: Material): InventoryGUI

Sets the background material for the inventory GUI.

Link copied to clipboard

Sets the button to be displayed when the paginated GUI has no items to show.

Link copied to clipboard

Sets multiple items at once for the GUI. This replaces the existing item list.

Link copied to clipboard

Sets the number of items that should be displayed per page in the GUI.

Link copied to clipboard

Sets the listener for handling GUI events.

Link copied to clipboard

Sets the buttons used to navigate between pages in the paginated GUI. The provided buttons will be assigned click actions to move to the previous or next page.

Link copied to clipboard

Sets the button provider function for generating buttons based on the current state. This function is called to create a list of buttons whenever the state changes, allowing for dynamic button generation.

Link copied to clipboard
@ApiStatus.Internal
fun setPageItems(items: List<Button>): PaginatedDynamicGUI<S>

Sets the items to be paginated.

Link copied to clipboard

Specifies which states should use pagination.

Link copied to clipboard
fun setShouldCallGlobalListener(shouldCallGlobalListener: Boolean): InventoryGUI

Sets whether the global listener should be called on inventory events.

Link copied to clipboard

Sets the size of the inventory GUI.

Link copied to clipboard

Sets the slot positions for the inventory GUI.

Link copied to clipboard

Updates the current state of the paginated dynamic GUI and resets the current page to the first one.

Link copied to clipboard

Sets the providers for fixed buttons associated with each state.

Link copied to clipboard
fun setTitle(title: Component): InventoryGUI

Sets the title of the inventory GUI.

Link copied to clipboard

Sets the total number of pages. This method should be called after setting up items.

Link copied to clipboard

Indicates whether the global listener should be called on inventory events.

Link copied to clipboard
fun switchPage(page: Int)

Switches the current page of the paginated GUI to the specified page index and updates its display.

Link copied to clipboard
fun switchState(state: S)

Switches the current state of the GUI to the specified state. If the given state is different from the current state, it updates the state, resets the current page to the first page (index 0), and updates the display.