Package net.kyori.adventure.text
Interface ComponentBuilder<C extends BuildableComponent<C,B>,B extends ComponentBuilder<C,B>>
- Type Parameters:
C
- the component typeB
- the builder type
- All Superinterfaces:
AbstractBuilder<C>
,Buildable.Builder<C>
,ComponentBuilderApplicable
,ComponentLike
,MutableStyleSetter<B>
,StyleSetter<B>
- All Known Subinterfaces:
BlockNBTComponent.Builder
,EntityNBTComponent.Builder
,KeybindComponent.Builder
,NBTComponentBuilder<C,
,B> ScoreComponent.Builder
,SelectorComponent.Builder
,StorageNBTComponent.Builder
,TextComponent.Builder
,TranslatableComponent.Builder
@NonExtendable
public interface ComponentBuilder<C extends BuildableComponent<C,B>,B extends ComponentBuilder<C,B>>
extends AbstractBuilder<C>, Buildable.Builder<C>, ComponentBuilderApplicable, ComponentLike, MutableStyleSetter<B>
A component builder.
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionappend
(@NotNull Iterable<? extends ComponentLike> components) Appends components to this component.Appends a component to this component.Appends components to this component.default B
append
(@NotNull ComponentBuilder<?, ?> builder) Appends a component to this component.default B
append
(@NotNull ComponentLike component) Appends a component to this component.append
(@NotNull ComponentLike @NotNull ... components) Appends components to this component.default B
Appends a newline to this component.default B
Appends a space to this component.default B
applicableApply
(@NotNull ComponentBuilderApplicable applicable) Appliesapplicable
.default B
apply
(@NotNull Consumer<? super ComponentBuilder<?, ?>> consumer) Applies an action to this builder.applyDeep
(@NotNull Consumer<? super ComponentBuilder<?, ?>> action) Applies an action to this component and all child components if they are an instance ofBuildableComponent
.default @NotNull Component
Gets aComponent
representation.build()
Build a component.children()
Get an unmodifiable list containing all children currently in this builder.clickEvent
(@Nullable ClickEvent event) Sets the click event of this component.Sets the color of this component.colorIfAbsent
(@Nullable TextColor color) Sets the color of this component if there isn't one set already.default void
componentBuilderApply
(@NotNull ComponentBuilder<?, ?> component) Applies tocomponent
.default B
decorate
(@NotNull TextDecoration decoration) Sets the state ofdecoration
toTextDecoration.State.TRUE
.default B
decorate
(@NotNull TextDecoration @NotNull ... decorations) Setsdecorations
toTextDecoration.State.TRUE
.default B
decoration
(@NotNull TextDecoration decoration, boolean flag) Sets the state of a decoration on this component.decoration
(@NotNull TextDecoration decoration, @NotNull TextDecoration.State state) Sets the value of a decoration on this component.decorationIfAbsent
(@NotNull TextDecoration decoration, @NotNull TextDecoration.State state) Sets the state of a decoration on this component tostate
if the current state of the decoration isTextDecoration.State.NOT_SET
.default B
decorations
(@NotNull Map<TextDecoration, TextDecoration.State> decorations) Sets decorations for this component's style using the specifieddecorations
map.default B
decorations
(@NotNull Set<TextDecoration> decorations, boolean flag) Sets the state of a set of decorations toflag
on this component.Sets the font of this component.hoverEvent
(@Nullable HoverEventSource<?> source) Sets the hover event of this component.Sets the string to be inserted when this component is shift-clicked.mapChildren
(@NotNull Function<BuildableComponent<?, ?>, ? extends BuildableComponent<?, ?>> function) Replaces each child of this component with the resultant component from the function.mapChildrenDeep
(@NotNull Function<BuildableComponent<?, ?>, ? extends BuildableComponent<?, ?>> function) Replaces each child and sub-child of this component with the resultant component of the function.default B
mergeStyle
(@NotNull Component that) Merges styling from another component into this component.mergeStyle
(@NotNull Component that, @NotNull Set<Style.Merge> merges) Merges styling from another component into this component.default B
mergeStyle
(@NotNull Component that, @NotNull Style.Merge @NotNull ... merges) Merges styling from another component into this component.Resets all styling on this component.style
(@NotNull Consumer<Style.Builder> consumer) Configures the style.Sets the style.Methods inherited from interface net.kyori.adventure.text.format.StyleSetter
shadowColor, shadowColorIfAbsent
-
Method Details
-
append
Appends a component to this component.- Parameters:
component
- the component to append- Returns:
- this builder
- Since:
- 4.0.0
-
append
Appends a component to this component.- Parameters:
component
- the component to append- Returns:
- this builder
- Since:
- 4.0.0
-
append
Appends a component to this component.- Parameters:
builder
- the component to append- Returns:
- this builder
- Since:
- 4.0.0
-
append
Appends components to this component.- Parameters:
components
- the components to append- Returns:
- this builder
- Since:
- 4.0.0
-
append
Appends components to this component.- Parameters:
components
- the components to append- Returns:
- this builder
- Since:
- 4.0.0
-
append
@Contract("_ -> this") @NotNull B append(@NotNull @NotNull Iterable<? extends ComponentLike> components) Appends components to this component.- Parameters:
components
- the components to append- Returns:
- this builder
- Since:
- 4.0.0
-
appendNewline
Appends a newline to this component.- Returns:
- this builder
- Since:
- 4.12.0
-
appendSpace
Appends a space to this component.- Returns:
- this builder
- Since:
- 4.12.0
-
apply
@Contract("_ -> this") @NotNull default B apply(@NotNull @NotNull Consumer<? super ComponentBuilder<?, ?>> consumer) Applies an action to this builder.- Parameters:
consumer
- the action- Returns:
- this builder
- Since:
- 4.0.0
-
applyDeep
@Contract("_ -> this") @NotNull B applyDeep(@NotNull @NotNull Consumer<? super ComponentBuilder<?, ?>> action) Applies an action to this component and all child components if they are an instance ofBuildableComponent
.- Parameters:
action
- the action- Returns:
- this builder
- Since:
- 4.0.0
-
mapChildren
@Contract("_ -> this") @NotNull B mapChildren(@NotNull @NotNull 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
@Contract("_ -> this") @NotNull B mapChildrenDeep(@NotNull @NotNull 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
-
children
Get an unmodifiable list containing all children currently in this builder.- Returns:
- the list of children
- Since:
- 4.6.0
-
style
Sets the style.- Parameters:
style
- the style- Returns:
- this builder
- Since:
- 4.0.0
-
style
Configures the style.- Parameters:
consumer
- the style consumer- Returns:
- this builder
- Since:
- 4.0.0
-
font
Sets the font of this component.- Specified by:
font
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
font
- the font- Returns:
- this builder
- Since:
- 4.0.0
-
color
Sets the color of this component.- Specified by:
color
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
color
- the color- Returns:
- this builder
- Since:
- 4.0.0
-
colorIfAbsent
Sets the color of this component if there isn't one set already.- Specified by:
colorIfAbsent
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
color
- the color- Returns:
- this builder
- Since:
- 4.0.0
-
decorations
@Contract("_, _ -> this") @NotNull default B decorations(@NotNull @NotNull Set<TextDecoration> decorations, boolean flag) Sets the state of a set of decorations toflag
on this component.- Specified by:
decorations
in interfaceMutableStyleSetter<C extends BuildableComponent<C,
B>> - Specified by:
decorations
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
decorations
- the decorationsflag
-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
Sets the state ofdecoration
toTextDecoration.State.TRUE
.- Specified by:
decorate
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
decoration
- the decoration- Returns:
- this builder
- Since:
- 4.0.0
-
decorate
@Contract("_ -> this") @NotNull default B decorate(@NotNull @NotNull TextDecoration @NotNull ... decorations) Setsdecorations
toTextDecoration.State.TRUE
.- Specified by:
decorate
in interfaceMutableStyleSetter<C extends BuildableComponent<C,
B>> - Specified by:
decorate
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
decorations
- the decorations- Returns:
- this builder
- Since:
- 4.0.0
-
decoration
@Contract("_, _ -> this") @NotNull default B decoration(@NotNull @NotNull TextDecoration decoration, boolean flag) Sets the state of a decoration on this component.- Specified by:
decoration
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
decoration
- the decorationflag
-true
if this component should have the decoration,false
if this component should not have the decoration- Returns:
- this builder
- Since:
- 4.0.0
-
decorations
@Contract("_ -> this") @NotNull default B decorations(@NotNull @NotNull Map<TextDecoration, TextDecoration.State> decorations) Sets decorations for this component's style using the specifieddecorations
map.If a given decoration does not have a value explicitly set, the value of that particular decoration is not changed.
- Specified by:
decorations
in interfaceMutableStyleSetter<C extends BuildableComponent<C,
B>> - Specified by:
decorations
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
decorations
- a map containing text decorations and their respective state.- Returns:
- this builder
- Since:
- 4.10.0
-
decoration
@Contract("_, _ -> this") @NotNull B decoration(@NotNull @NotNull TextDecoration decoration, @NotNull TextDecoration.State state) Sets the value of a decoration on this component.- Specified by:
decoration
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
decoration
- the decorationstate
-TextDecoration.State.TRUE
if this component should have the decoration,TextDecoration.State.FALSE
if this component should not have the decoration, andTextDecoration.State.NOT_SET
if the decoration should not have a set value- Returns:
- this builder
- Since:
- 4.0.0
-
decorationIfAbsent
@Contract("_, _ -> this") @NotNull B decorationIfAbsent(@NotNull @NotNull TextDecoration decoration, @NotNull TextDecoration.State state) Sets the state of a decoration on this component tostate
if the current state of the decoration isTextDecoration.State.NOT_SET
.- Specified by:
decorationIfAbsent
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
decoration
- the decorationstate
- the state- Returns:
- this builder
- Since:
- 4.12.0
-
clickEvent
Sets the click event of this component.- Specified by:
clickEvent
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
event
- the click event- Returns:
- this builder
- Since:
- 4.0.0
-
hoverEvent
Sets the hover event of this component.- Specified by:
hoverEvent
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
source
- the hover event source- Returns:
- this builder
- Since:
- 4.0.0
-
insertion
Sets the string to be inserted when this component is shift-clicked.- Specified by:
insertion
in interfaceStyleSetter<C extends BuildableComponent<C,
B>> - Parameters:
insertion
- the insertion string- Returns:
- this builder
- Since:
- 4.0.0
-
mergeStyle
Merges styling from another component into this component.- Parameters:
that
- the other component- Returns:
- this builder
- Since:
- 4.0.0
-
mergeStyle
@Contract("_, _ -> this") @NotNull default B mergeStyle(@NotNull @NotNull Component that, @NotNull Style.Merge @NotNull ... merges) Merges styling from another component into this component.- Parameters:
that
- the other componentmerges
- the parts to merge- Returns:
- this builder
- Since:
- 4.0.0
-
mergeStyle
@Contract("_, _ -> this") @NotNull B mergeStyle(@NotNull @NotNull Component that, @NotNull @NotNull Set<Style.Merge> merges) Merges styling from another component into this component.- Parameters:
that
- the other componentmerges
- the parts to merge- Returns:
- this builder
- Since:
- 4.0.0
-
resetStyle
Resets all styling on this component.- Returns:
- this builder
- Since:
- 4.0.0
-
build
Build a component.- Specified by:
build
in interfaceAbstractBuilder<C extends BuildableComponent<C,
B>> - Specified by:
build
in interfaceBuildable.Builder<C extends BuildableComponent<C,
B>> - Returns:
- the component
-
applicableApply
@Contract("_ -> this") @NotNull default B applicableApply(@NotNull @NotNull ComponentBuilderApplicable applicable) Appliesapplicable
.- Parameters:
applicable
- the thing to apply- Returns:
- this builder
- Since:
- 4.0.0
-
componentBuilderApply
Description copied from interface:ComponentBuilderApplicable
Applies tocomponent
.- Specified by:
componentBuilderApply
in interfaceComponentBuilderApplicable
- Parameters:
component
- the component builder
-
asComponent
Description copied from interface:ComponentLike
Gets aComponent
representation.- Specified by:
asComponent
in interfaceComponentLike
- Returns:
- a component
-