Interface ComponentBuilder<C extends BuildableComponent<C,​B>,​B extends ComponentBuilder<C,​B>>

Type Parameters:
C - the component type
B - the builder type
All Superinterfaces:
Buildable.Builder<C>, ComponentBuilderApplicable, ComponentLike
All Known Subinterfaces:
BlockNBTComponent.Builder, EntityNBTComponent.Builder, KeybindComponent.Builder, NBTComponentBuilder<C,​B>, ScoreComponent.Builder, SelectorComponent.Builder, StorageNBTComponent.Builder, TextComponent.Builder, TranslatableComponent.Builder

public interface ComponentBuilder<C extends BuildableComponent<C,​B>,​B extends ComponentBuilder<C,​B>>
extends Buildable.Builder<C>, ComponentBuilderApplicable, ComponentLike
A component builder.
Since:
4.0.0
  • Method Details

    • append

      @NonNull B append​(@NonNull Component component)
      Appends a component to this component.
      Parameters:
      component - the component to append
      Returns:
      this builder
      Since:
      4.0.0
    • append

      default @NonNull B append​(@NonNull ComponentLike component)
      Appends a component to this component.
      Parameters:
      component - the component to append
      Returns:
      this builder
      Since:
      4.0.0
    • append

      default @NonNull B append​(@NonNull ComponentBuilder<?,​?> builder)
      Appends a component to this component.
      Parameters:
      builder - the component to append
      Returns:
      this builder
      Since:
      4.0.0
    • append

      @NonNull B append​(@NonNull Component @NonNull ... components)
      Appends components to this component.
      Parameters:
      components - the components to append
      Returns:
      this builder
      Since:
      4.0.0
    • append

      @NonNull B append​(@NonNull ComponentLike @NonNull ... components)
      Appends components to this component.
      Parameters:
      components - the components to append
      Returns:
      this builder
      Since:
      4.0.0
    • append

      @NonNull B append​(@NonNull Iterable<? extends ComponentLike> components)
      Appends components to this component.
      Parameters:
      components - the components to append
      Returns:
      this builder
      Since:
      4.0.0
    • apply

      default @NonNull B apply​(@NonNull Consumer<? super ComponentBuilder<?,​?>> consumer)
      Applies an action to this builder.
      Parameters:
      consumer - the action
      Returns:
      this builder
      Since:
      4.0.0
    • applyDeep

      @NonNull B applyDeep​(@NonNull Consumer<? super ComponentBuilder<?,​?>> action)
      Applies an action to this component and all child components if they are an instance of BuildableComponent.
      Parameters:
      action - the action
      Returns:
      this builder
      Since:
      4.0.0
    • mapChildren

      @NonNull B mapChildren​(@NonNull Function<BuildableComponent<?,​?>,​? extends BuildableComponent<?,​?>> function)
      Replaces each child of this component with the resultant component from the function.
      Parameters:
      function - the mapping function
      Returns:
      this builder
      Since:
      4.0.0
    • mapChildrenDeep

      @NonNull B mapChildrenDeep​(@NonNull Function<BuildableComponent<?,​?>,​? extends BuildableComponent<?,​?>> function)
      Replaces each child and sub-child of this component with the resultant component of the function.
      Parameters:
      function - the mapping function
      Returns:
      this builder
      Since:
      4.0.0
    • style

      @NonNull B style​(@NonNull Style style)
      Sets the style.
      Parameters:
      style - the style
      Returns:
      this builder
      Since:
      4.0.0
    • style

      @NonNull B style​(@NonNull Consumer<Style.Builder> consumer)
      Configures the style.
      Parameters:
      consumer - the style consumer
      Returns:
      this builder
      Since:
      4.0.0
    • font

      @NonNull B font​(@Nullable Key font)
      Sets the font of this component.
      Parameters:
      font - the font
      Returns:
      this builder
      Since:
      4.0.0
    • color

      @NonNull B color​(@Nullable TextColor color)
      Sets the color of this component.
      Parameters:
      color - the color
      Returns:
      this builder
      Since:
      4.0.0
    • colorIfAbsent

      @NonNull B colorIfAbsent​(@Nullable TextColor color)
      Sets the color of this component if there isn't one set already.
      Parameters:
      color - the color
      Returns:
      this builder
      Since:
      4.0.0
    • decorations

      default @NonNull B decorations​(@NonNull Set<TextDecoration> decorations, boolean flag)
      Sets the state of a set of decorations to flag on this component.
      Parameters:
      decorations - the decorations
      flag - true if this component should have the decorations, false if this component should not have the decorations
      Returns:
      this builder
      Since:
      4.0.0
    • decorate

      default @NonNull B decorate​(@NonNull TextDecoration decoration)
      Sets the state of decoration to TextDecoration.State.TRUE.
      Parameters:
      decoration - the decoration
      Returns:
      this builder
      Since:
      4.0.0
    • decorate

      default @NonNull B decorate​(@NonNull TextDecoration @NonNull ... decorations)
      Sets decorations to TextDecoration.State.TRUE.
      Parameters:
      decorations - the decorations
      Returns:
      this builder
      Since:
      4.0.0
    • decoration

      default @NonNull B decoration​(@NonNull TextDecoration decoration, boolean flag)
      Sets the state of a decoration on this component.
      Parameters:
      decoration - the decoration
      flag - true if this component should have the decoration, false if this component should not have the decoration
      Returns:
      this builder
      Since:
      4.0.0
    • decoration

      @NonNull B decoration​(@NonNull TextDecoration decoration, @NonNull TextDecoration.State state)
      Sets the value of a decoration on this component.
      Parameters:
      decoration - the decoration
      state - TextDecoration.State.TRUE if this component should have the decoration, TextDecoration.State.FALSE if this component should not have the decoration, and TextDecoration.State.NOT_SET if the decoration should not have a set value
      Returns:
      this builder
      Since:
      4.0.0
    • clickEvent

      @NonNull B clickEvent​(@Nullable ClickEvent event)
      Sets the click event of this component.
      Parameters:
      event - the click event
      Returns:
      this builder
      Since:
      4.0.0
    • hoverEvent

      @NonNull B hoverEvent​(@Nullable HoverEventSource<?> source)
      Sets the hover event of this component.
      Parameters:
      source - the hover event source
      Returns:
      this builder
      Since:
      4.0.0
    • insertion

      @NonNull B insertion​(@Nullable String insertion)
      Sets the string to be inserted when this component is shift-clicked.
      Parameters:
      insertion - the insertion string
      Returns:
      this builder
      Since:
      4.0.0
    • mergeStyle

      default @NonNull B mergeStyle​(@NonNull Component that)
      Merges styling from another component into this component.
      Parameters:
      that - the other component
      Returns:
      this builder
      Since:
      4.0.0
    • mergeStyle

      default @NonNull B mergeStyle​(@NonNull Component that, @NonNull Style.Merge @NonNull ... merges)
      Merges styling from another component into this component.
      Parameters:
      that - the other component
      merges - the parts to merge
      Returns:
      this builder
      Since:
      4.0.0
    • mergeStyle

      @NonNull B mergeStyle​(@NonNull Component that, @NonNull Set<Style.Merge> merges)
      Merges styling from another component into this component.
      Parameters:
      that - the other component
      merges - the parts to merge
      Returns:
      this builder
      Since:
      4.0.0
    • resetStyle

      @NonNull B resetStyle()
      Resets all styling on this component.
      Returns:
      this builder
      Since:
      4.0.0
    • build

      @NonNull C build()
      Build a component.
      Specified by:
      build in interface Buildable.Builder<C extends BuildableComponent<C,​B>>
      Returns:
      the component
    • applicableApply

      default @NonNull B applicableApply​(@NonNull ComponentBuilderApplicable applicable)
      Applies applicable.
      Parameters:
      applicable - the thing to apply
      Returns:
      this builder
      Since:
      4.0.0
    • componentBuilderApply

      default void componentBuilderApply​(@NonNull ComponentBuilder<?,​?> component)
      Description copied from interface: ComponentBuilderApplicable
      Applies to component.
      Specified by:
      componentBuilderApply in interface ComponentBuilderApplicable
      Parameters:
      component - the component builder
    • asComponent

      default @NonNull Component asComponent()
      Description copied from interface: ComponentLike
      Gets a Component representation.
      Specified by:
      asComponent in interface ComponentLike
      Returns:
      a component