Class ItemComponentBuilderImpl

java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.internal.component.ItemComponentBuilderImpl
All Implemented Interfaces:
ItemComponentBuilder

@Internal public final class ItemComponentBuilderImpl extends Object implements ItemComponentBuilder
Mutable collector behind ItemComponentBuilder; gathers a component declaration and materializes it into an immutable ComponentInstance bound to fixed slots.
  • Constructor Details

    • ItemComponentBuilderImpl

      public ItemComponentBuilderImpl()
  • Method Details

    • item

      @NotNull public @NotNull ItemComponentBuilder item(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Description copied from interface: ItemComponentBuilder
      Sets a static item for this component.
      Specified by:
      item in interface ItemComponentBuilder
      Parameters:
      item - the item to display
      Returns:
      this builder
    • item

      @NotNull public @NotNull ItemComponentBuilder item(@NotNull @NotNull Function<ViewContext,org.bukkit.inventory.ItemStack> renderer)
      Description copied from interface: ItemComponentBuilder
      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.
      Specified by:
      item in interface ItemComponentBuilder
      Parameters:
      renderer - the per-render item factory
      Returns:
      this builder
    • displayIf

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

      @NotNull public @NotNull ItemComponentBuilder updateOnStateChange(@NotNull @NotNull StateToken... tokens)
      Description copied from interface: ItemComponentBuilder
      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.
      Specified by:
      updateOnStateChange in interface ItemComponentBuilder
      Parameters:
      tokens - the state tokens to watch
      Returns:
      this builder
    • onClick

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

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

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

      @NotNull public @NotNull ItemComponentBuilder closeOnClick()
      Description copied from interface: ItemComponentBuilder
      Closes the view after a click on this component; deferred to the end of the tick.
      Specified by:
      closeOnClick in interface ItemComponentBuilder
      Returns:
      this builder
    • openOnClick

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

      @NotNull public @NotNull ItemComponentBuilder openOnClick(@NotNull @NotNull Class<? extends View> target, @NotNull @NotNull ViewArguments arguments)
      Description copied from interface: ItemComponentBuilder
      Same as ItemComponentBuilder.openOnClick(Class), passing arguments to the target view.
      Specified by:
      openOnClick in interface ItemComponentBuilder
      Parameters:
      target - the registered view class to open
      arguments - the arguments handed to the target's contexts
      Returns:
      this builder
    • materialize

      @NotNull public @NotNull ComponentInstance materialize(@NotNull @org.jetbrains.annotations.NotNull int[] slots)
      Freezes the collected declaration into a component bound to the given slots.
      Parameters:
      slots - the container slots this component paints, in paint order
      Returns:
      the immutable materialized component