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 Type
    Method
    Description
    void
    Applies a Layout: every mapped character is written to its slots.
    boolean
    Returns to the previous view in the player's history, if any.
    void
    Runs bulk mutations without sending per-slot packets, then pushes one full refresh at the end.
    void
    Clears every slot.
    void
    Closes this view.
    The per-open key/value context (survives view switches via history).
    void
    fill(ViewItem item)
    Fills every slot with the item.
    void
    Fills the outer border (first/last row and first/last column).
    void
    fillColumn(int column, ViewItem item)
    Fills one column (zero-based).
    void
    Fills only slots that are currently empty.
    void
    fillRect(int rowFrom, int columnFrom, int rowTo, int columnTo, ViewItem item)
    Fills the rectangle from (rowFrom, columnFrom) to (rowTo, columnTo), both inclusive.
    void
    fillRow(int row, ViewItem item)
    Fills one row (zero-based).
    get(int slot)
    The item currently at a flat slot index, or null if empty.
    get(int row, int column)
    The item currently at a row/column position, or null if empty.
    boolean
    Whether this view is still open for the player.
    void
    open(View view)
    Opens another view, pushing the current one onto the player's back-history.
    void
    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.Player
    The player viewing this GUI.
    void
    Re-sends the full window contents to the client.
    void
    remove(int slot)
    Clears one slot.
    Schedules a repeating task on the proxy scheduler, cancelled automatically when this view closes or the player switches views.
    void
    set(int row, int column, ViewItem item)
    Sets or replaces the item at a row/column position.
    void
    set(int slot, ViewItem item)
    Sets or replaces the item at a flat slot index.
    void
    set(Slot slot, ViewItem item)
    Sets or replaces the item at a Slot position.
    int
    Number of slots in the top (GUI) inventory.
    void
    title(net.kyori.adventure.text.Component title)
    Changes the window title in place (re-opens the same window id client-side).
    The window type.
    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

      void set(int slot, ViewItem item)
      Sets or replaces the item at a flat slot index. null clears the slot.
    • set

      void set(int row, int column, ViewItem item)
      Sets or replaces the item at a row/column position. null clears the slot.
    • set

      void set(Slot slot, ViewItem item)
      Sets or replaces the item at a Slot position.
    • get

      ViewItem get(int slot)
      The item currently at a flat slot index, or null if empty.
    • get

      ViewItem get(int row, int column)
      The item currently at a row/column position, or null if empty.
    • remove

      void remove(int slot)
      Clears one slot.
    • fill

      void fill(ViewItem item)
      Fills every slot with the item.
    • fillEmpty

      void fillEmpty(ViewItem item)
      Fills only slots that are currently empty.
    • fillRow

      void fillRow(int row, ViewItem item)
      Fills one row (zero-based).
    • fillColumn

      void fillColumn(int column, ViewItem item)
      Fills one column (zero-based).
    • fillBorder

      void fillBorder(ViewItem item)
      Fills the outer border (first/last row and first/last column).
    • fillRect

      void fillRect(int rowFrom, int columnFrom, int rowTo, int columnTo, ViewItem item)
      Fills the rectangle from (rowFrom, columnFrom) to (rowTo, columnTo), both inclusive.
    • applyLayout

      void applyLayout(Layout layout)
      Applies a Layout: every mapped character is written to its slots.
    • clear

      void clear()
      Clears every slot.
    • batch

      void batch(Consumer<ViewContents> mutations)
      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

      UpdateTask 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.
      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

      void open(View view)
      Opens another view, pushing the current one onto the player's back-history.
    • openReplacing

      void openReplacing(View view)
      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.