Interface ItemComponentBuilder

All Known Implementing Classes:
ItemComponentBuilderImpl

@NonExtendable public interface ItemComponentBuilder
Fluent declaration of one item component, returned by RenderContext.slot(...)/layoutSlot(...). Declaration order is paint order; all callbacks run on the main thread, engine-invoked. A component must declare an item source via item(...) — one without fails at first render with ViewConfigurationException.
  • Method Details

    • item

      @NotNull @NotNull ItemComponentBuilder item(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Sets a static item for this component.
      Parameters:
      item - the item to display
      Returns:
      this builder
    • item

      @NotNull @NotNull ItemComponentBuilder item(@NotNull @NotNull Function<ViewContext,org.bukkit.inventory.ItemStack> renderer)
      Sets a dynamic item renderer, re-evaluated on every re-render of this component. Renderer failures keep the previous slot content and are logged rate-limited.
      Parameters:
      renderer - the per-render item factory
      Returns:
      this builder
    • displayIf

      @NotNull @NotNull ItemComponentBuilder displayIf(@NotNull @NotNull Predicate<ViewContext> condition)
      Shows this component only while the condition holds; a hidden component's slots are cleared and it receives no clicks.
      Parameters:
      condition - evaluated on every re-render of this component
      Returns:
      this builder
    • updateOnStateChange

      @NotNull @NotNull ItemComponentBuilder updateOnStateChange(@NotNull @NotNull StateToken... tokens)
      Re-renders this component whenever one of the given tokens changes, at most once per flush. Dependencies are explicit — there is no automatic read tracking.
      Parameters:
      tokens - the state tokens to watch
      Returns:
      this builder
    • onClick

      @NotNull @NotNull ItemComponentBuilder onClick(@NotNull @NotNull Consumer<SlotClickContext> handler)
      Sets the untyped click handler; it runs only when no per-ClickType handler matched the click.
      Parameters:
      handler - the fallback click handler
      Returns:
      this builder
    • onClick

      @NotNull @NotNull ItemComponentBuilder onClick(@NotNull @NotNull org.bukkit.event.inventory.ClickType type, @NotNull @NotNull Consumer<SlotClickContext> handler)
      Sets the handler for one specific click type; it takes precedence over the untyped handler.
      Parameters:
      type - the click type to match
      handler - the click handler
      Returns:
      this builder
    • cancelOnClick

      @NotNull @NotNull ItemComponentBuilder cancelOnClick(boolean cancel)
      Overrides the config-level click cancellation for this component's slots; handlers may still overturn the decision via SlotClickContext.setCancelled(boolean).
      Parameters:
      cancel - whether clicks on this component are pre-cancelled
      Returns:
      this builder
    • closeOnClick

      @NotNull @NotNull ItemComponentBuilder closeOnClick()
      Closes the view after a click on this component; deferred to the end of the tick.
      Returns:
      this builder
    • openOnClick

      @NotNull @NotNull ItemComponentBuilder openOnClick(@NotNull @NotNull Class<? extends View> target)
      Navigates to another registered view after a click on this component; deferred to the end of the tick.
      Parameters:
      target - the registered view class to open
      Returns:
      this builder
    • openOnClick

      @NotNull @NotNull ItemComponentBuilder openOnClick(@NotNull @NotNull Class<? extends View> target, @NotNull @NotNull ViewArguments arguments)
      Same as openOnClick(Class), passing arguments to the target view.
      Parameters:
      target - the registered view class to open
      arguments - the arguments handed to the target's contexts
      Returns:
      this builder