Class ViewBuilder
java.lang.Object
me.agent.vgui.api.ViewBuilder
Fluent builder for views. It builds complete menus without subclassing
View.
Obtain via VGui.chest(int) or VGui.view(ViewType).
The produced View is immutable and reusable: open it for any number of
players; per-player state lives in each player's ViewContents.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the immutable, reusable view.cancelClientTransactions(boolean cancel) clickCooldown(Duration cooldown) Places an item at a row/column position (applied after the layout).Places an item at a flat slot index (applied after the layout).Sets a character-mask layout.Maps a layout character to an item ('.'and' 'stay empty).onAnvilInput(BiConsumer<String, ViewContents> onAnvilInput) Runs on anvil rename input (only forViewType.ANVILviews).onClick(Consumer<ClickContext> onClick) Runs for every click (after any per-item handler).onClose(CloseHandler onClose) Runs when the view closes.onOpen(Consumer<ViewContents> onOpen) Runs after the layout and items are applied when the view opens for a player.title(net.kyori.adventure.text.Component title) Sets the window title.updateEvery(Duration interval, Consumer<ViewContents> task) Registers a repeating update task started when the view opens and cancelled when it closes.
-
Method Details
-
title
Sets the window title. -
layout
Sets a character-mask layout. Row count and width must match the view type (e.g. 9 characters per row for chests). Map characters withmap(char, ViewItem). -
map
Maps a layout character to an item ('.'and' 'stay empty). -
item
Places an item at a flat slot index (applied after the layout). -
item
Places an item at a row/column position (applied after the layout). -
onOpen
Runs after the layout and items are applied when the view opens for a player. -
onClick
Runs for every click (after any per-item handler). -
onClose
Runs when the view closes. -
onAnvilInput
Runs on anvil rename input (only forViewType.ANVILviews). -
updateEvery
Registers a repeating update task started when the view opens and cancelled when it closes. This is useful for animations and live data. -
cancelClientTransactions
SeeView.cancelClientTransactions(). Defaulttrue. -
clickCooldown
SeeView.clickCooldownMillis(). Default: disabled. -
build
Builds the immutable, reusable view.
-