Class ChestView

java.lang.Object
me.agent.vgui.api.ChestView
All Implemented Interfaces:
View

public abstract class ChestView extends Object implements View
Convenience base class for static 9xN chest menus: call setItem(int, ViewItem) in your constructor and the items are applied every time the view opens. For dynamic menus override onOpen(ViewContents) (call super.onOpen(contents) to keep the static items) or use VGui.chest(int).
  • Constructor Details

    • ChestView

      protected ChestView(int rows, net.kyori.adventure.text.Component title)
  • Method Details

    • rows

      public final int rows()
      Number of chest rows (1-6).
    • size

      public final int size()
      Total slot count (rows() * 9).
    • title

      public final net.kyori.adventure.text.Component title()
      Description copied from interface: View
      Title shown on the container.
      Specified by:
      title in interface View
    • type

      public final ViewType type()
      Description copied from interface: View
      The window type (determines slot count and shape).
      Specified by:
      type in interface View
    • setItem

      protected final void setItem(int slot, ViewItem item)
      Sets or replaces a static item; null removes it. Ignores out-of-range slots.
    • setItem

      protected final void setItem(int row, int column, ViewItem item)
      Sets or replaces a static item at a row/column position.
      Throws:
      IllegalArgumentException - if the coordinate is outside this chest
    • onOpen

      public void onOpen(ViewContents contents)
      Description copied from interface: View
      Called right after the window opens (and again if the view is re-opened via back-navigation). Populate contents here; mutations made inside this callback are sent as one batch.
      Specified by:
      onOpen in interface View