Class ComponentInstance
java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.internal.component.ComponentInstance
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final org.bukkit.inventory.ItemStackIdentity sentinel returned byrenderForPaint(tech.guilhermekaua.spigotboot.inventoryapi.context.ViewContext)when evaluation failed: the caller must skip painting so the slot keeps its previous content. -
Method Summary
Modifier and TypeMethodDescription@Nullable Booleanboolean@Nullable Consumer<SlotClickContext>handlerFor(@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.booleanisVisible(@NotNull ViewContext ctx) Evaluates thedisplayIfpredicate; visible by default.@NotNull ViewArguments@Nullable org.bukkit.inventory.ItemStackrenderForPaint(@NotNull ViewContext ctx) Single paint entry point: returns null to clear the slot (hidden component), theRENDER_FAILUREsentinel (compare by identity) when displayIf or the renderer threw, or the item to paint.@Nullable org.bukkit.inventory.ItemStackrenderItem(@NotNull ViewContext ctx) Produces this component's item: the static item, or the renderer applied to the context.@org.jetbrains.annotations.NotNull int[]slots()@org.jetbrains.annotations.NotNull int[]
-
Field Details
-
RENDER_FAILURE
public static final org.bukkit.inventory.ItemStack RENDER_FAILUREIdentity sentinel returned byrenderForPaint(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
Evaluates thedisplayIfpredicate; 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. UserenderForPaint(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), theRENDER_FAILUREsentinel (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_CLICKis 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 typedonClick(DOUBLE_CLICK, ...)handler still opts in. -
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
- Returns:
- the view opened on click, or null when no navigation was declared
-
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
-