Class DefaultViewContents

java.lang.Object
me.agent.vgui.core.internal.DefaultViewContents
All Implemented Interfaces:
ViewContents

public final class DefaultViewContents extends Object implements ViewContents
Live contents backing one ViewSession. Mutations send minimal packets unless batching, and become no-ops once the session closes.
  • 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.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • player

      public com.velocitypowered.api.proxy.Player player()
      Description copied from interface: ViewContents
      The player viewing this GUI.
      Specified by:
      player in interface ViewContents
    • view

      public View view()
      Description copied from interface: ViewContents
      The view definition these contents belong to.
      Specified by:
      view in interface ViewContents
    • type

      public ViewType type()
      Description copied from interface: ViewContents
      The window type.
      Specified by:
      type in interface ViewContents
    • size

      public int size()
      Description copied from interface: ViewContents
      Number of slots in the top (GUI) inventory.
      Specified by:
      size in interface ViewContents
    • context

      public ViewContext context()
      Description copied from interface: ViewContents
      The per-open key/value context (survives view switches via history).
      Specified by:
      context in interface ViewContents
    • isOpen

      public boolean isOpen()
      Description copied from interface: ViewContents
      Whether this view is still open for the player.
      Specified by:
      isOpen in interface ViewContents
    • set

      public void set(int slot, ViewItem item)
      Description copied from interface: ViewContents
      Sets or replaces the item at a flat slot index. null clears the slot.
      Specified by:
      set in interface ViewContents
    • set

      public void set(int row, int column, ViewItem item)
      Description copied from interface: ViewContents
      Sets or replaces the item at a row/column position. null clears the slot.
      Specified by:
      set in interface ViewContents
    • set

      public void set(Slot slot, ViewItem item)
      Description copied from interface: ViewContents
      Sets or replaces the item at a Slot position.
      Specified by:
      set in interface ViewContents
    • get

      public ViewItem get(int slot)
      Description copied from interface: ViewContents
      The item currently at a flat slot index, or null if empty.
      Specified by:
      get in interface ViewContents
    • get

      public ViewItem get(int row, int column)
      Description copied from interface: ViewContents
      The item currently at a row/column position, or null if empty.
      Specified by:
      get in interface ViewContents
    • remove

      public void remove(int slot)
      Description copied from interface: ViewContents
      Clears one slot.
      Specified by:
      remove in interface ViewContents
    • fill

      public void fill(ViewItem item)
      Description copied from interface: ViewContents
      Fills every slot with the item.
      Specified by:
      fill in interface ViewContents
    • fillEmpty

      public void fillEmpty(ViewItem item)
      Description copied from interface: ViewContents
      Fills only slots that are currently empty.
      Specified by:
      fillEmpty in interface ViewContents
    • fillRow

      public void fillRow(int row, ViewItem item)
      Description copied from interface: ViewContents
      Fills one row (zero-based).
      Specified by:
      fillRow in interface ViewContents
    • fillColumn

      public void fillColumn(int column, ViewItem item)
      Description copied from interface: ViewContents
      Fills one column (zero-based).
      Specified by:
      fillColumn in interface ViewContents
    • fillBorder

      public void fillBorder(ViewItem item)
      Description copied from interface: ViewContents
      Fills the outer border (first/last row and first/last column).
      Specified by:
      fillBorder in interface ViewContents
    • fillRect

      public void fillRect(int rowFrom, int columnFrom, int rowTo, int columnTo, ViewItem item)
      Description copied from interface: ViewContents
      Fills the rectangle from (rowFrom, columnFrom) to (rowTo, columnTo), both inclusive.
      Specified by:
      fillRect in interface ViewContents
    • applyLayout

      public void applyLayout(Layout layout)
      Description copied from interface: ViewContents
      Applies a Layout: every mapped character is written to its slots.
      Specified by:
      applyLayout in interface ViewContents
    • clear

      public void clear()
      Description copied from interface: ViewContents
      Clears every slot.
      Specified by:
      clear in interface ViewContents
    • batch

      public void batch(Consumer<ViewContents> mutations)
      Description copied from interface: ViewContents
      Runs bulk mutations without sending per-slot packets, then pushes one full refresh at the end.
      Specified by:
      batch in interface ViewContents
    • refresh

      public void refresh()
      Description copied from interface: ViewContents
      Re-sends the full window contents to the client.
      Specified by:
      refresh in interface ViewContents
    • title

      public void title(net.kyori.adventure.text.Component title)
      Description copied from interface: ViewContents
      Changes the window title in place (re-opens the same window id client-side).
      Specified by:
      title in interface ViewContents
    • schedule

      public UpdateTask schedule(Duration interval, Consumer<ViewContents> task)
      Description copied from interface: ViewContents
      Schedules a repeating task on the proxy scheduler, cancelled automatically when this view closes or the player switches views.
      Specified by:
      schedule in interface ViewContents
      Parameters:
      interval - time between runs (minimum 50ms)
      task - receives these contents on every run
      Returns:
      a handle to cancel the task early
    • pagination

      public Pagination pagination()
      Description copied from interface: ViewContents
      The pagination helper for this view (lazily created, one per open view).
      Specified by:
      pagination in interface ViewContents
    • close

      public void close()
      Description copied from interface: ViewContents
      Closes this view.
      Specified by:
      close in interface ViewContents
    • open

      public void open(View view)
      Description copied from interface: ViewContents
      Opens another view, pushing the current one onto the player's back-history.
      Specified by:
      open in interface ViewContents
    • openReplacing

      public void openReplacing(View view)
      Description copied from interface: ViewContents
      Opens another view without pushing the current one onto the back-history.
      Specified by:
      openReplacing in interface ViewContents
    • back

      public boolean back()
      Description copied from interface: ViewContents
      Returns to the previous view in the player's history, if any.
      Specified by:
      back in interface ViewContents