java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.internal.component.ComponentInstance

@Internal public final class ComponentInstance extends Object
Immutable materialized item component: fixed slots, item source, visibility predicate, click handlers, post-actions and watched token ids. Renderer and predicate failures are swallowed and logged at most once per minute per instance (§9 error table).
  • Field Details

    • RENDER_FAILURE

      public static final org.bukkit.inventory.ItemStack RENDER_FAILURE
      Identity sentinel returned by renderForPaint(tech.guilhermekaua.spigotboot.inventoryapi.context.ViewContext) when evaluation failed: the caller must skip painting so the slot keeps its previous content. This instance must never be mutated and must never be passed to SlotPainter.paint; its content is meaningless — it exists only for identity comparison.
  • Method Details

    • slots

      @NotNull public @org.jetbrains.annotations.NotNull int[] slots()
      Returns:
      the container slots this component paints, in paint order
    • isVisible

      public boolean isVisible(@NotNull @NotNull ViewContext ctx)
      Evaluates the displayIf predicate; visible by default.
      Returns:
      false when the predicate returns false or throws (throw is rate-limit logged)
    • renderItem

      @Nullable public @Nullable org.bukkit.inventory.ItemStack renderItem(@NotNull @NotNull ViewContext ctx)
      Produces this component's item: the static item, or the renderer applied to the context. Use renderForPaint(tech.guilhermekaua.spigotboot.inventoryapi.context.ViewContext) for all paint paths; this method is for non-paint introspection only (exceptions yield null here, not the failure sentinel).
      Returns:
      the item, or null when the renderer throws (throw is rate-limit logged)
    • renderForPaint

      @Nullable public @Nullable org.bukkit.inventory.ItemStack renderForPaint(@NotNull @NotNull ViewContext ctx)
      Single paint entry point: returns null to clear the slot (hidden component), the RENDER_FAILURE sentinel (compare by identity) when displayIf or the renderer threw, or the item to paint.
      Parameters:
      ctx - the rendering context
      Returns:
      the item, null, or the failure sentinel
    • handlerFor

      @Nullable public @Nullable Consumer<SlotClickContext> handlerFor(@NotNull @NotNull org.bukkit.event.inventory.ClickType type)
      Resolves the handler for a click: the matching per-type handler, else the untyped default handler, else null. ClickType.DOUBLE_CLICK is the one exception — it never falls back to the untyped default: Minecraft delivers the collect-to-cursor double-click as a synthetic second event of a fast double-tap, so routing it to the untyped handler would run the action twice. A deliberately typed onClick(DOUBLE_CLICK, ...) handler still opts in.
    • cancelOnClick

      @Nullable public @Nullable Boolean cancelOnClick()
      Returns:
      the per-component cancellation override, or null to inherit the config default
    • closeOnClick

      public boolean closeOnClick()
      Returns:
      true when a click on this component closes the view at end of tick
    • openOnClickTarget

      @Nullable public @Nullable Class<? extends View> openOnClickTarget()
      Returns:
      the view opened on click, or null when no navigation was declared
    • openOnClickArguments

      @NotNull public @NotNull ViewArguments openOnClickArguments()
      Returns:
      the arguments passed to the open-on-click target; empty when none were given
    • watchedTokenIds

      @NotNull public @org.jetbrains.annotations.NotNull int[] watchedTokenIds()
      Returns:
      the watched token ids in declaration order