java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.internal.context.AbstractViewContext
tech.guilhermekaua.spigotboot.inventoryapi.internal.context.OpenContextImpl
All Implemented Interfaces:
OpenContext, ViewContext, StateBackedContext

@Internal public final class OpenContextImpl extends AbstractViewContext implements OpenContext
Context for View.onOpen: records per-open overrides and the cancel decision. No container exists yet, so inventory(), update() and updateTitle(String) throw IllegalStateException naming the phase.
  • Constructor Details

    • OpenContextImpl

      public OpenContextImpl(@NotNull @NotNull ViewSession session, @NotNull @NotNull ViewEngine engine)
      Creates the context for one open attempt.
      Parameters:
      session - the session being opened
      engine - the engine executing the open
  • Method Details

    • overrideTitle

      public void overrideTitle(@NotNull @NotNull String title)
      Description copied from interface: OpenContext
      Overrides the configured title for this open only.
      Specified by:
      overrideTitle in interface OpenContext
      Parameters:
      title - the per-open title, legacy color codes supported
    • overrideRows

      public void overrideRows(int rows)
      Description copied from interface: OpenContext
      Overrides the configured row count for this open only.
      Specified by:
      overrideRows in interface OpenContext
      Parameters:
      rows - the per-open row count, 1 to 6
    • cancelOpen

      public void cancelOpen()
      Description copied from interface: OpenContext
      Aborts this open with zero side effects; the player's current view is untouched.
      Specified by:
      cancelOpen in interface OpenContext
    • isOpenCancelled

      public boolean isOpenCancelled()
      Description copied from interface: OpenContext
      Returns whether OpenContext.cancelOpen() was called for this open.
      Specified by:
      isOpenCancelled in interface OpenContext
      Returns:
      true when this open is cancelled
    • overriddenTitle

      @Nullable public @Nullable String overriddenTitle()
      Returns the per-open title override recorded in onOpen.
      Returns:
      the overridden title, or null when none was recorded
    • overriddenRows

      @Nullable public @Nullable Integer overriddenRows()
      Returns the per-open rows override recorded in onOpen.
      Returns:
      the overridden row count, or null when none was recorded
    • inventory

      @NotNull public @NotNull org.bukkit.inventory.Inventory inventory()
      Description copied from interface: ViewContext
      Returns the top container of this session.
      Specified by:
      inventory in interface ViewContext
      Overrides:
      inventory in class AbstractViewContext
      Returns:
      the Bukkit inventory backing this view
    • update

      public void update()
      Description copied from interface: ViewContext
      Runs a full update pass (UpdateTrigger.EXPLICIT) synchronously: onUpdate followed by a component repaint. State written during the pass is coalesced into a single trailing flush. Main thread only.
      Specified by:
      update in interface ViewContext
      Overrides:
      update in class AbstractViewContext
    • updateTitle

      public void updateTitle(@NotNull @NotNull String title)
      Description copied from interface: ViewContext
      Updates the container title in place (no reopen) via the title updater: placeholders are applied for ViewContext.player() when enabled by the view config, then legacy & color codes are translated. Main thread only.
      Specified by:
      updateTitle in interface ViewContext
      Overrides:
      updateTitle in class AbstractViewContext
      Parameters:
      title - the new title, legacy color codes supported