Interface ComponentBuilder<C extends Component, B extends ComponentBuilder<C,B>>
- Type Parameters:
C- the component typeB- the builder type
- All Superinterfaces:
AbstractBuilder<C>, ComponentBuilderApplicable, ComponentLike, MutableStyleSetter<B>, StyleSetter<B>
- All Known Subinterfaces:
BlockNBTComponent.Builder, EntityNBTComponent.Builder, KeybindComponent.Builder, NBTComponentBuilder<C,B>, ObjectComponent.Builder, ScoreComponent.Builder, SelectorComponent.Builder, StorageNBTComponent.Builder, TextComponent.Builder, TranslatableComponent.Builder
@NonExtendable
public sealed interface ComponentBuilder<C extends Component, B extends ComponentBuilder<C,B>>
extends AbstractBuilder<C>, ComponentBuilderApplicable, ComponentLike, MutableStyleSetter<B>
permits KeybindComponent.Builder, NBTComponentBuilder<C,B>, ObjectComponent.Builder, ScoreComponent.Builder, SelectorComponent.Builder, TextComponent.Builder, TranslatableComponent.Builder (not exhaustive)
A component builder.
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionappend(Iterable<? extends ComponentLike> components) Appends components to this component.Appends a component to this component.Appends components to this component.default Bappend(ComponentBuilder<?, ?> builder) Appends a component to this component.default Bappend(ComponentLike component) Appends a component to this component.append(ComponentLike... components) Appends components to this component.default BAppends a newline to this component.default BAppends a space to this component.default BapplicableApply(ComponentBuilderApplicable applicable) Appliesapplicable.default Bapply(Consumer<? super ComponentBuilder<?, ?>> consumer) Applies an action to this builder.applyDeep(Consumer<? super ComponentBuilder<?, ?>> action) Applies an action to this component and all child components.default ComponentGets aComponentrepresentation.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 voidcomponentBuilderApply(ComponentBuilder<?, ?> component) Applies tocomponent.default Bdecorate(TextDecoration decoration) Sets the state ofdecorationtoTextDecoration.State.TRUE.default Bdecorate(TextDecoration... decorations) SetsdecorationstoTextDecoration.State.TRUE.default Bdecoration(TextDecoration decoration, boolean flag) Sets the state of a decoration on this component.decoration(TextDecoration decoration, TextDecoration.State state) Sets the value of a decoration on this component.decorationIfAbsent(TextDecoration decoration, TextDecoration.State state) Sets the state of a decoration on this component tostateif the current state of the decoration isTextDecoration.State.NOT_SET.default Bdecorations(Map<TextDecoration, TextDecoration.State> decorations) Sets decorations for this component's style using the specifieddecorationsmap.default Bdecorations(Set<TextDecoration> decorations, boolean flag) Sets the state of a set of decorations toflagon 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(Function<Component, ? extends Component> function) Replaces each child of this component with the resultant component from the function.mapChildrenDeep(Function<Component, ? extends Component> function) Replaces each child and sub-child of this component with the resultant component of the function.default BmergeStyle(Component that) Merges styling from another component into this component.mergeStyle(Component that, Set<Style.Merge> merges) Merges styling from another component into this component.default BmergeStyle(Component that, Style.Merge... merges) Merges styling from another component into this component.Resets all styling on this component.style(Consumer<Style.Builder> consumer) Configures the style.Sets the style.Methods inherited from interface StyleSetter
shadowColor, shadowColorIfAbsent
-
Method Details
-
append
-
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
-
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
-
appendNewline
-
appendSpace
-
apply
Applies an action to this builder.- Parameters:
consumer- the action- Returns:
- this builder
- Since:
- 4.0.0
-
applyDeep
Applies an action to this component and all child components.- Parameters:
action- the action- Returns:
- this builder
- Since:
- 4.0.0
-
mapChildren
-
mapChildrenDeep
-
children
-
style
-
style
Configures the style.- Parameters:
consumer- the style consumer- Returns:
- this builder
- Since:
- 4.0.0
-
font
-
color
-
colorIfAbsent
Sets the color of this component if there isn't one set already.- Specified by:
colorIfAbsentin interfaceStyleSetter<C extends Component>- Parameters:
color- the color- Returns:
- this builder
- Since:
- 4.0.0
-
decorations
Sets the state of a set of decorations toflagon this component.- Specified by:
decorationsin interfaceMutableStyleSetter<C extends Component>- Specified by:
decorationsin interfaceStyleSetter<C extends Component>- Parameters:
decorations- the decorationsflag-trueif this component should have the decorations,falseif this component should not have the decorations- Returns:
- this builder
- Since:
- 4.0.0
-
decorate
Sets the state ofdecorationtoTextDecoration.State.TRUE.- Specified by:
decoratein interfaceStyleSetter<C extends Component>- Parameters:
decoration- the decoration- Returns:
- this builder
- Since:
- 4.0.0
-
decorate
SetsdecorationstoTextDecoration.State.TRUE.- Specified by:
decoratein interfaceMutableStyleSetter<C extends Component>- Specified by:
decoratein interfaceStyleSetter<C extends Component>- Parameters:
decorations- the decorations- Returns:
- this builder
- Since:
- 4.0.0
-
decoration
Sets the state of a decoration on this component.- Specified by:
decorationin interfaceStyleSetter<C extends Component>- Parameters:
decoration- the decorationflag-trueif this component should have the decoration,falseif this component should not have the decoration- Returns:
- this builder
- Since:
- 4.0.0
-
decorations
Sets decorations for this component's style using the specifieddecorationsmap.If a given decoration does not have a value explicitly set, the value of that particular decoration is not changed.
- Specified by:
decorationsin interfaceMutableStyleSetter<C extends Component>- Specified by:
decorationsin interfaceStyleSetter<C extends Component>- Parameters:
decorations- a map containing text decorations and their respective state.- Returns:
- this builder
- Since:
- 4.10.0
-
decoration
Sets the value of a decoration on this component.- Specified by:
decorationin interfaceStyleSetter<C extends Component>- Parameters:
decoration- the decorationstate-TextDecoration.State.TRUEif this component should have the decoration,TextDecoration.State.FALSEif this component should not have the decoration, andTextDecoration.State.NOT_SETif the decoration should not have a set value- Returns:
- this builder
- Since:
- 4.0.0
-
decorationIfAbsent
@Contract("_, _ -> this") B decorationIfAbsent(TextDecoration decoration, TextDecoration.State state) Sets the state of a decoration on this component tostateif the current state of the decoration isTextDecoration.State.NOT_SET.- Specified by:
decorationIfAbsentin interfaceStyleSetter<C extends Component>- Parameters:
decoration- the decorationstate- the state- Returns:
- this builder
- Since:
- 4.12.0
-
clickEvent
Sets the click event of this component.- Specified by:
clickEventin interfaceStyleSetter<C extends Component>- Parameters:
event- the click event- Returns:
- this builder
- Since:
- 4.0.0
-
hoverEvent
Sets the hover event of this component.- Specified by:
hoverEventin interfaceStyleSetter<C extends Component>- Parameters:
source- the hover event source- Returns:
- this builder
- Since:
- 4.0.0
-
insertion
-
mergeStyle
-
mergeStyle
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
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
-
build
C build()Build a component.- Specified by:
buildin interfaceAbstractBuilder<C extends Component>- Returns:
- the component
-
applicableApply
Appliesapplicable.- Parameters:
applicable- the thing to apply- Returns:
- this builder
- Since:
- 4.0.0
-
componentBuilderApply
Description copied from interface:ComponentBuilderApplicableApplies tocomponent.- Specified by:
componentBuilderApplyin interfaceComponentBuilderApplicable- Parameters:
component- the component builder
-
asComponent
Description copied from interface:ComponentLikeGets aComponentrepresentation.- Specified by:
asComponentin interfaceComponentLike- Returns:
- a component
-