Interface ViewContents
- All Known Implementing Classes:
DefaultViewContents
public interface ViewContents
The live, mutable contents of one player's open view. Created when a view opens and
discarded when it closes. Every mutation is pushed to the client immediately as a
single-slot update or a full window refresh. Wrap bulk changes in
batch(Consumer) to send one refresh instead.
All methods are safe to call from click handlers and update tasks. If the view has already closed, mutations are silently ignored.
-
Method Summary
Modifier and TypeMethodDescriptionvoidapplyLayout(Layout layout) Applies aLayout: every mapped character is written to its slots.booleanback()Returns to the previous view in the player's history, if any.voidbatch(Consumer<ViewContents> mutations) Runs bulk mutations without sending per-slot packets, then pushes one full refresh at the end.voidclear()Clears every slot.voidclose()Closes this view.context()The per-open key/value context (survives view switches via history).voidFills every slot with the item.voidfillBorder(ViewItem item) Fills the outer border (first/last row and first/last column).voidfillColumn(int column, ViewItem item) Fills one column (zero-based).voidFills only slots that are currently empty.voidFills the rectangle from (rowFrom, columnFrom) to (rowTo, columnTo), both inclusive.voidFills one row (zero-based).get(int slot) The item currently at a flat slot index, ornullif empty.get(int row, int column) The item currently at a row/column position, ornullif empty.booleanisOpen()Whether this view is still open for the player.voidOpens another view, pushing the current one onto the player's back-history.voidopenReplacing(View view) Opens another view without pushing the current one onto the back-history.The pagination helper for this view (lazily created, one per open view).com.velocitypowered.api.proxy.Playerplayer()The player viewing this GUI.voidrefresh()Re-sends the full window contents to the client.voidremove(int slot) Clears one slot.schedule(Duration interval, Consumer<ViewContents> task) Schedules a repeating task on the proxy scheduler, cancelled automatically when this view closes or the player switches views.voidSets or replaces the item at a row/column position.voidSets or replaces the item at a flat slot index.voidSets or replaces the item at aSlotposition.intsize()Number of slots in the top (GUI) inventory.voidtitle(net.kyori.adventure.text.Component title) Changes the window title in place (re-opens the same window id client-side).type()The window type.view()The view definition these contents belong to.
-
Method Details
-
player
com.velocitypowered.api.proxy.Player player()The player viewing this GUI. -
view
View view()The view definition these contents belong to. -
type
ViewType type()The window type. -
size
int size()Number of slots in the top (GUI) inventory. -
context
ViewContext context()The per-open key/value context (survives view switches via history). -
isOpen
boolean isOpen()Whether this view is still open for the player. -
set
Sets or replaces the item at a flat slot index.nullclears the slot. -
set
Sets or replaces the item at a row/column position.nullclears the slot. -
set
-
get
The item currently at a flat slot index, ornullif empty. -
get
The item currently at a row/column position, ornullif empty. -
remove
void remove(int slot) Clears one slot. -
fill
Fills every slot with the item. -
fillEmpty
Fills only slots that are currently empty. -
fillRow
Fills one row (zero-based). -
fillColumn
Fills one column (zero-based). -
fillBorder
Fills the outer border (first/last row and first/last column). -
fillRect
Fills the rectangle from (rowFrom, columnFrom) to (rowTo, columnTo), both inclusive. -
applyLayout
-
clear
void clear()Clears every slot. -
batch
Runs bulk mutations without sending per-slot packets, then pushes one full refresh at the end. -
refresh
void refresh()Re-sends the full window contents to the client. -
title
void title(net.kyori.adventure.text.Component title) Changes the window title in place (re-opens the same window id client-side). -
schedule
Schedules a repeating task on the proxy scheduler, cancelled automatically when this view closes or the player switches views.- Parameters:
interval- time between runs (minimum 50ms)task- receives these contents on every run- Returns:
- a handle to cancel the task early
-
pagination
Pagination pagination()The pagination helper for this view (lazily created, one per open view). -
close
void close()Closes this view. -
open
Opens another view, pushing the current one onto the player's back-history. -
openReplacing
Opens another view without pushing the current one onto the back-history. -
back
boolean back()Returns to the previous view in the player's history, if any.
-