PaginatedGuiContext

abstract class PaginatedGuiContext<T>(val rows: Int) : GuiContext

A context class for GUIs that support pagination.

Parameters

rows

The number of rows in the GUI.

Constructors

Link copied to clipboard
constructor(rows: Int)

Properties

Link copied to clipboard

The current page index (0-indexed).

Link copied to clipboard
lateinit var inventory: Inventory

The underlying Bukkit inventory managed by this GUI.

Link copied to clipboard
var items: List<T>

The list of items to be paginated.

Link copied to clipboard

The number of items to display per page.

Link copied to clipboard
val rows: Int
Link copied to clipboard

The total number of pages.

Functions

Link copied to clipboard
abstract fun build()

Builds the GUI. This is where you define slots and states.

override fun build(creator: GuiCreator)

Builds the GUI using the provided GuiCreator.

Link copied to clipboard
fun content(slots: List<Int>, display: SlotCreator.(T) -> Unit)

DSL for defining how to display each item in the list.

fun content(range: IntRange, display: SlotCreator.(T) -> Unit)

DSL for defining how to display each item in the list using a range of slots.

Link copied to clipboard
fun fill(material: Material, pickable: Boolean = false, creator: SlotCreator.() -> Unit = {})

Fills all slots in the GUI with a material.

Link copied to clipboard
fun fillBorder(material: Material, pickable: Boolean = false, creator: SlotCreator.() -> Unit = {})

Fills the border of the GUI with a material.

Link copied to clipboard
fun fillRect(s1: Slot, s2: Slot, material: Material, pickable: Boolean = false, creator: SlotCreator.() -> Unit = {})

Fills a rectangular area defined by two slots with a material.

fun fillRect(x1: Int, y1: Int, x2: Int, y2: Int, material: Material, pickable: Boolean = false, creator: SlotCreator.() -> Unit = {})

Fills a rectangular area of the GUI with a material.

Link copied to clipboard
fun nextPage()

Goes to the next page.

Link copied to clipboard
fun open(player: Player)

Opens the GUI for the specified player.

Link copied to clipboard
fun prevPage()

Goes to the previous page.

Link copied to clipboard
fun slot(slot: Slot, creator: SlotCreator.() -> Unit)

Configures a slot by a Slot instance.

fun slot(slot: Int, creator: SlotCreator.() -> Unit)

Configures a slot by its raw index (0-indexed).

fun slot(x: Int, y: Int, creator: SlotCreator.() -> Unit)

Configures a slot by its X and Y coordinates (1-indexed).

Link copied to clipboard
fun <T> state(initial: T): GuiContext.GuiState<T>

Creates a state delegate for this GUI. Changing the state will automatically trigger update.

Link copied to clipboard
fun GuiContext.template(template: GuiContext.() -> Unit)

Includes another builder block as a template.

Link copied to clipboard
fun title(title: Component)

Sets the title of the GUI.

Link copied to clipboard
fun update()

Generates or updates the inventory based on the current configuration. This should be called whenever the GUI's state changes.