Interface Component
- All Superinterfaces:
ComponentBuilderApplicable
,ComponentLike
,net.kyori.examination.Examinable
,HoverEventSource<Component>
- All Known Subinterfaces:
BlockNBTComponent
,BuildableComponent<C,B>
,EntityNBTComponent
,KeybindComponent
,NBTComponent<C,B>
,ScopedComponent<C>
,ScoreComponent
,SelectorComponent
,StorageNBTComponent
,TextComponent
,TranslatableComponent
- All Known Implementing Classes:
AbstractComponent
@NonExtendable public interface Component extends ComponentBuilderApplicable, ComponentLike, net.kyori.examination.Examinable, HoverEventSource<Component>
Components can be thought of as the combination of:
- The message the Component wants to display; and
- The
Style
of that message.
The most basic component is the TextComponent
,
where the message is a simple String. However, other dynamic
Components are available, which are linked to from here and you
are encouraged to explore to better support your plugin/mod.
Factories and builders for all available component types are
provided via this interface.
Components can be serialized to and deserialized from other
formats via the use of component
serializers
. If used within one of our natively supported platforms,
the availability of such serializers may vary, consult the documentation
or support for the given platform should this be the case.
Further information about Components, along with functional examples of how they can be used, can be found on our documentation.
- Since:
- 4.0.0
- See Also:
BlockNBTComponent
,EntityNBTComponent
,KeybindComponent
,ScoreComponent
,SelectorComponent
,StorageNBTComponent
,TextComponent
,TranslatableComponent
,LinearComponents
-
Method Summary
Modifier and Type Method Description @NonNull Component
append(@NonNull Component component)
Appends a component to this component.default @NonNull Component
append(@NonNull ComponentBuilder<?,?> builder)
Appends a component to this component.default @NonNull Component
append(@NonNull ComponentLike component)
Appends a component to this component.default @NonNull Component
asComponent()
Gets aComponent
representation.default @NonNull HoverEvent<Component>
asHoverEvent(@NonNull UnaryOperator<Component> op)
Creates a hover event with value derived from this object.static @NonNull BlockNBTComponent.Builder
blockNBT()
Creates a block NBT component builder.static @NonNull BlockNBTComponent
blockNBT(@NonNull String nbtPath, boolean interpret, @NonNull BlockNBTComponent.Pos pos)
Creates a block NBT component with a position.static @NonNull BlockNBTComponent
blockNBT(@NonNull String nbtPath, @NonNull BlockNBTComponent.Pos pos)
Creates a block NBT component with a position.static @NonNull BlockNBTComponent
blockNBT(@NonNull Consumer<? super BlockNBTComponent.Builder> consumer)
Creates a block NBT component by applying configuration fromconsumer
.@Unmodifiable @NonNull List<Component>
children()
Gets the unmodifiable list of children.@NonNull Component
children(@NonNull List<? extends ComponentLike> children)
Sets the list of children.default @Nullable ClickEvent
clickEvent()
Gets the click event of this component.default @NonNull Component
clickEvent(@Nullable ClickEvent event)
Sets the click event of this component.default @Nullable TextColor
color()
Gets the color of this component.default @NonNull Component
color(@Nullable TextColor color)
Sets the color of this component.default @NonNull Component
colorIfAbsent(@Nullable TextColor color)
Sets the color if there isn't one set already.default void
componentBuilderApply(@NonNull ComponentBuilder<?,?> component)
Applies tocomponent
.default boolean
contains(@NonNull Component that)
Checks if this component contains a component.default @NonNull Component
decorate(@NonNull TextDecoration decoration)
Sets the state ofdecoration
toTextDecoration.State.TRUE
on this component.default @NonNull TextDecoration.State
decoration(@NonNull TextDecoration decoration)
Gets the state of a decoration on this component.default @NonNull Component
decoration(@NonNull TextDecoration decoration, boolean flag)
Sets the state of a decoration on this component.default @NonNull Component
decoration(@NonNull TextDecoration decoration, @NonNull TextDecoration.State state)
Sets the value of a decoration on this component.default @NonNull Map<TextDecoration,TextDecoration.State>
decorations()
Gets a set of decorations this component has.default @NonNull Component
decorations(@NonNull Map<TextDecoration,TextDecoration.State> decorations)
Sets decorations for this component's style using the specifieddecorations
map.default void
detectCycle(@NonNull Component that)
Deprecated.static @NonNull TextComponent
empty()
Gets an empty component.static @NonNull EntityNBTComponent.Builder
entityNBT()
Creates an entity NBT component builder.static @NonNull EntityNBTComponent
entityNBT(@NonNull String nbtPath, @NonNull String selector)
Creates a entity NBT component with a position.static @NonNull EntityNBTComponent
entityNBT(@NonNull Consumer<? super EntityNBTComponent.Builder> consumer)
Creates a entity NBT component by applying configuration fromconsumer
.default boolean
hasDecoration(@NonNull TextDecoration decoration)
Tests if this component has a decoration.default boolean
hasStyling()
Tests if this component has any styling.default @Nullable HoverEvent<?>
hoverEvent()
Gets the hover event of this component.default @NonNull Component
hoverEvent(@Nullable HoverEventSource<?> source)
Sets the hover event of this component.default @Nullable String
insertion()
Gets the string to be inserted when this component is shift-clicked.default @NonNull Component
insertion(@Nullable String insertion)
Sets the string to be inserted when this component is shift-clicked.static @NonNull TextComponent
join(@NonNull ComponentLike separator, @NonNull ComponentLike @NonNull ... components)
Joinscomponents
usingseparator
.static @NonNull TextComponent
join(@NonNull ComponentLike separator, Iterable<? extends ComponentLike> components)
Joinscomponents
usingseparator
.static @NonNull KeybindComponent.Builder
keybind()
Creates a keybind component builder.static @NonNull KeybindComponent
keybind(@NonNull String keybind)
Creates a keybind component with a keybind.static @NonNull KeybindComponent
keybind(@NonNull String keybind, @NonNull Style style)
Creates a keybind component with a keybind and styling.static @NonNull KeybindComponent
keybind(@NonNull String keybind, @Nullable TextColor color)
Creates a keybind component with a keybind, and optional color.static @NonNull KeybindComponent
keybind(@NonNull String keybind, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)
Creates a keybind component with a keybind, and optional color and decorations.static @NonNull KeybindComponent
keybind(@NonNull String keybind, @Nullable TextColor color, TextDecoration @NonNull ... decorations)
Creates a keybind component with a keybind, and optional color and decorations.static @NonNull KeybindComponent
keybind(@NonNull Consumer<? super KeybindComponent.Builder> consumer)
Creates a keybind component by applying configuration fromconsumer
.default @NonNull Component
mergeStyle(@NonNull Component that)
Merges from another style into this component's style.default @NonNull Component
mergeStyle(@NonNull Component that, @NonNull Set<Style.Merge> merges)
Merges from another style into this component's style.default @NonNull Component
mergeStyle(@NonNull Component that, @NonNull Style.Merge @NonNull ... merges)
Merges from another style into this component's style.static @NonNull TextComponent
newline()
Gets a text component with a new line character as the content.default @NonNull Component
replaceFirstText(@NonNull String search, @Nullable ComponentLike replacement)
Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.default @NonNull Component
replaceFirstText(@NonNull Pattern pattern, @NonNull Function<TextComponent.Builder,@Nullable ComponentLike> replacement)
Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.default @NonNull Component
replaceText(@NonNull String search, @Nullable ComponentLike replacement)
Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.default @NonNull Component
replaceText(@NonNull String search, @Nullable ComponentLike replacement, int numberOfReplacements)
Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.default @NonNull Component
replaceText(@NonNull String search, @Nullable ComponentLike replacement, @NonNull IntFunction2<PatternReplacementResult> fn)
Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.@NonNull Component
replaceText(@NonNull Consumer<TextReplacementConfig.Builder> configurer)
Finds and replaces any text with this or childComponent
s using the configured options.default @NonNull Component
replaceText(@NonNull Pattern pattern, @NonNull Function<TextComponent.Builder,@Nullable ComponentLike> replacement)
Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.default @NonNull Component
replaceText(@NonNull Pattern pattern, @NonNull Function<TextComponent.Builder,@Nullable ComponentLike> replacement, int numberOfReplacements)
Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.default @NonNull Component
replaceText(@NonNull Pattern pattern, @NonNull Function<TextComponent.Builder,@Nullable ComponentLike> replacement, @NonNull IntFunction2<PatternReplacementResult> fn)
Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.@NonNull Component
replaceText(@NonNull TextReplacementConfig config)
Finds and replaces any text with this or childComponent
s using the provided options.static @NonNull ScoreComponent.Builder
score()
Creates a score component builder.static @NonNull ScoreComponent
score(@NonNull String name, @NonNull String objective)
Creates a score component with a name and objective.static @NonNull ScoreComponent
score(@NonNull String name, @NonNull String objective, @Nullable String value)
Deprecated.since 4.7.0, not for removal, with no replacement.static @NonNull ScoreComponent
score(@NonNull Consumer<? super ScoreComponent.Builder> consumer)
Creates a score component by applying configuration fromconsumer
.static @NonNull SelectorComponent.Builder
selector()
Creates a selector component builder.static @NonNull SelectorComponent
selector(@NonNull String pattern)
Creates a selector component with a pattern.static @NonNull SelectorComponent
selector(@NonNull Consumer<? super SelectorComponent.Builder> consumer)
Creates a selector component by applying configuration fromconsumer
.static @NonNull TextComponent
space()
Gets a text immutable component with a single space as the content.static @NonNull StorageNBTComponent.Builder
storageNBT()
Creates an storage NBT component builder.static @NonNull StorageNBTComponent
storageNBT(@NonNull String nbtPath, boolean interpret, @NonNull net.kyori.adventure.key.Key storage)
Creates a storage NBT component with a path and an storage ID.static @NonNull StorageNBTComponent
storageNBT(@NonNull String nbtPath, @NonNull net.kyori.adventure.key.Key storage)
Creates a storage NBT component with a path and an storage ID.static @NonNull StorageNBTComponent
storageNBT(@NonNull Consumer<? super StorageNBTComponent.Builder> consumer)
Creates a storage NBT component by applying configuration fromconsumer
.@NonNull Style
style()
Gets the style of this component.default @NonNull Component
style(@NonNull Consumer<Style.Builder> consumer)
Sets the style of this component.default @NonNull Component
style(@NonNull Consumer<Style.Builder> consumer, @NonNull Style.Merge.Strategy strategy)
Sets the style of this component.@NonNull Component
style(@NonNull Style style)
Sets the style of this component.default @NonNull Component
style(@NonNull Style.Builder style)
Sets the style of this component.static @NonNull TextComponent.Builder
text()
Creates a text component builder.static @NonNull TextComponent
text(boolean value)
Creates a text component with the content ofString.valueOf(boolean)
.static @NonNull TextComponent
text(boolean value, @NonNull Style style)
Creates a text component with the content ofString.valueOf(boolean)
and styling.static @NonNull TextComponent
text(boolean value, @Nullable TextColor color)
Creates a text component with the content ofString.valueOf(boolean)
, and optional color.static @NonNull TextComponent
text(boolean value, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)
Creates a text component with the content ofString.valueOf(boolean)
, and optional color and decorations.static @NonNull TextComponent
text(boolean value, @Nullable TextColor color, TextDecoration @NonNull ... decorations)
Creates a text component with the content ofString.valueOf(boolean)
, and optional color and decorations.static @NonNull TextComponent
text(char value)
Creates a text component with the content ofString.valueOf(char)
.static @NonNull TextComponent
text(char value, @NonNull Style style)
Creates a text component with the content ofString.valueOf(char)
and styling.static @NonNull TextComponent
text(char value, @Nullable TextColor color)
Creates a text component with the content ofString.valueOf(char)
, and optional color.static @NonNull TextComponent
text(char value, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)
Creates a text component with the content ofString.valueOf(char)
, and optional color and decorations.static @NonNull TextComponent
text(char value, @Nullable TextColor color, TextDecoration @NonNull ... decorations)
Creates a text component with the content ofString.valueOf(char)
, and optional color and decorations.static @NonNull TextComponent
text(double value)
Creates a text component with the content ofString.valueOf(double)
.static @NonNull TextComponent
text(double value, @NonNull Style style)
Creates a text component with the content ofString.valueOf(double)
and styling.static @NonNull TextComponent
text(double value, @Nullable TextColor color)
Creates a text component with the content ofString.valueOf(double)
, and optional color.static @NonNull TextComponent
text(double value, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)
Creates a text component with the content ofString.valueOf(double)
, and optional color and decorations.static @NonNull TextComponent
text(double value, @Nullable TextColor color, TextDecoration @NonNull ... decorations)
Creates a text component with the content ofString.valueOf(double)
, and optional color and decorations.static @NonNull TextComponent
text(float value)
Creates a text component with the content ofString.valueOf(float)
.static @NonNull TextComponent
text(float value, @NonNull Style style)
Creates a text component with the content ofString.valueOf(float)
and styling.static @NonNull TextComponent
text(float value, @Nullable TextColor color)
Creates a text component with the content ofString.valueOf(float)
, and optional color.static @NonNull TextComponent
text(float value, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)
Creates a text component with the content ofString.valueOf(float)
, and optional color and decorations.static @NonNull TextComponent
text(float value, @Nullable TextColor color, TextDecoration @NonNull ... decorations)
Creates a text component with the content ofString.valueOf(float)
, and optional color and decorations.static @NonNull TextComponent
text(int value)
Creates a text component with the content ofString.valueOf(int)
.static @NonNull TextComponent
text(int value, @NonNull Style style)
Creates a text component with the content ofString.valueOf(int)
and styling.static @NonNull TextComponent
text(int value, @Nullable TextColor color)
Creates a text component with the content ofString.valueOf(int)
, and optional color.static @NonNull TextComponent
text(int value, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)
Creates a text component with the content ofString.valueOf(int)
, and optional color and decorations.static @NonNull TextComponent
text(int value, @Nullable TextColor color, TextDecoration @NonNull ... decorations)
Creates a text component with the content ofString.valueOf(int)
, and optional color and decorations.static @NonNull TextComponent
text(long value)
Creates a text component with the content ofString.valueOf(long)
.static @NonNull TextComponent
text(long value, @NonNull Style style)
Creates a text component with the content ofString.valueOf(long)
and styling.static @NonNull TextComponent
text(long value, @Nullable TextColor color)
Creates a text component with the content ofString.valueOf(long)
, and optional color.static @NonNull TextComponent
text(long value, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)
Creates a text component with the content ofString.valueOf(long)
, and optional color and decorations.static @NonNull TextComponent
text(long value, @Nullable TextColor color, TextDecoration @NonNull ... decorations)
Creates a text component with the content ofString.valueOf(long)
, and optional color and decorations.static @NonNull TextComponent
text(@NonNull String content)
Creates a text component with content.static @NonNull TextComponent
text(@NonNull String content, @NonNull Style style)
Creates a text component with content and styling.static @NonNull TextComponent
text(@NonNull String content, @Nullable TextColor color)
Creates a text component with content, and optional color.static @NonNull TextComponent
text(@NonNull String content, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)
Creates a text component with content, and optional color and decorations.static @NonNull TextComponent
text(@NonNull String content, @Nullable TextColor color, TextDecoration @NonNull ... decorations)
Creates a text component with content, and optional color and decorations.static @NonNull TextComponent
text(@NonNull Consumer<? super TextComponent.Builder> consumer)
Creates a text component by applying configuration fromconsumer
.static @NonNull Collector<Component,? extends ComponentBuilder<?,?>,Component>
toComponent()
Create a collector that will join components without a separator.static @NonNull Collector<Component,? extends ComponentBuilder<?,?>,Component>
toComponent(@NonNull Component separator)
Create a collector that will join components using the provided separator.static @NonNull TranslatableComponent.Builder
translatable()
Creates a translatable component builder.static @NonNull TranslatableComponent
translatable(@NonNull String key)
Creates a translatable component with a translation key.static @NonNull TranslatableComponent
translatable(@NonNull String key, @NonNull List<? extends ComponentLike> args)
Creates a translatable component with a translation key and arguments.static @NonNull TranslatableComponent
translatable(@NonNull String key, @NonNull ComponentLike @NonNull ... args)
Creates a translatable component with a translation key and arguments.static @NonNull TranslatableComponent
translatable(@NonNull String key, @NonNull Style style)
Creates a translatable component with a translation key and styling.static @NonNull TranslatableComponent
translatable(@NonNull String key, @NonNull Style style, @NonNull List<? extends ComponentLike> args)
Creates a translatable component with a translation key and styling.static @NonNull TranslatableComponent
translatable(@NonNull String key, @NonNull Style style, @NonNull ComponentLike @NonNull ... args)
Creates a translatable component with a translation key and styling.static @NonNull TranslatableComponent
translatable(@NonNull String key, @Nullable TextColor color)
Creates a translatable component with a translation key, and optional color.static TranslatableComponent
translatable(@NonNull String key, @Nullable TextColor color, @NonNull List<? extends ComponentLike> args)
Creates a translatable component with a translation key, arguments, and optional color.static @NonNull TranslatableComponent
translatable(@NonNull String key, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)
Creates a translatable component with a translation key, and optional color and decorations.static @NonNull TranslatableComponent
translatable(@NonNull String key, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations, @NonNull List<? extends ComponentLike> args)
Creates a translatable component with a translation key, arguments, and optional color and decorations.static @NonNull TranslatableComponent
translatable(@NonNull String key, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations, @NonNull ComponentLike @NonNull ... args)
Creates a translatable component with a translation key, arguments, and optional color and decorations.static @NonNull TranslatableComponent
translatable(@NonNull String key, @Nullable TextColor color, @NonNull ComponentLike @NonNull ... args)
Creates a translatable component with a translation key, arguments, and optional color.static @NonNull TranslatableComponent
translatable(@NonNull String key, @Nullable TextColor color, TextDecoration @NonNull ... decorations)
Creates a translatable component with a translation key, and optional color and decorations.static @NonNull TranslatableComponent
translatable(@NonNull Consumer<? super TranslatableComponent.Builder> consumer)
Creates a translatable component by applying configuration fromconsumer
.Methods inherited from interface net.kyori.examination.Examinable
examinableName, examinableProperties, examine
Methods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEvent
-
Method Details
-
empty
Gets an empty component.- Returns:
- an empty component
- Since:
- 4.0.0
-
newline
Gets a text component with a new line character as the content.- Returns:
- a text component with a new line character as the content
- Since:
- 4.0.0
-
space
Gets a text immutable component with a single space as the content.- Returns:
- a text component with a single space as the content
- Since:
- 4.0.0
-
join
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent join(@NonNull ComponentLike separator, @NonNull ComponentLike @NonNull ... components)Joinscomponents
usingseparator
.- Parameters:
separator
- the separatorcomponents
- the components- Returns:
- a text component
- Since:
- 4.0.0
-
join
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent join(@NonNull ComponentLike separator, Iterable<? extends ComponentLike> components)Joinscomponents
usingseparator
.- Parameters:
separator
- the separatorcomponents
- the components- Returns:
- a text component
- Since:
- 4.0.0
-
toComponent
Create a collector that will join components without a separator.- Returns:
- a collector that can join components
- Since:
- 4.6.0
-
toComponent
static @NonNull Collector<Component,? extends ComponentBuilder<?,?>,Component> toComponent(@NonNull Component separator)Create a collector that will join components using the provided separator.- Parameters:
separator
- the separator to join with- Returns:
- a collector that can join components
- Since:
- 4.6.0
-
blockNBT
Creates a block NBT component builder.- Returns:
- a builder
- Since:
- 4.0.0
-
blockNBT
@Contract("_ -> new") static @NonNull BlockNBTComponent blockNBT(@NonNull Consumer<? super BlockNBTComponent.Builder> consumer)Creates a block NBT component by applying configuration fromconsumer
.- Parameters:
consumer
- the builder configurator- Returns:
- a block NBT component
- Since:
- 4.0.0
-
blockNBT
@Contract(value="_, _ -> new", pure=true) static @NonNull BlockNBTComponent blockNBT(@NonNull String nbtPath, @NonNull BlockNBTComponent.Pos pos)Creates a block NBT component with a position.- Parameters:
nbtPath
- the nbt pathpos
- the block position- Returns:
- a block NBT component
- Since:
- 4.0.0
-
blockNBT
@Contract(value="_, _, _ -> new", pure=true) static @NonNull BlockNBTComponent blockNBT(@NonNull String nbtPath, boolean interpret, @NonNull BlockNBTComponent.Pos pos)Creates a block NBT component with a position.- Parameters:
nbtPath
- the nbt pathinterpret
- whether to interpretpos
- the block position- Returns:
- a block NBT component
- Since:
- 4.0.0
-
entityNBT
Creates an entity NBT component builder.- Returns:
- a builder
- Since:
- 4.0.0
-
entityNBT
@Contract("_ -> new") static @NonNull EntityNBTComponent entityNBT(@NonNull Consumer<? super EntityNBTComponent.Builder> consumer)Creates a entity NBT component by applying configuration fromconsumer
.- Parameters:
consumer
- the builder configurator- Returns:
- an entity NBT component
- Since:
- 4.0.0
-
entityNBT
@Contract("_, _ -> new") static @NonNull EntityNBTComponent entityNBT(@NonNull String nbtPath, @NonNull String selector)Creates a entity NBT component with a position.- Parameters:
nbtPath
- the nbt pathselector
- the selector- Returns:
- an entity NBT component
- Since:
- 4.0.0
-
keybind
Creates a keybind component builder.- Returns:
- a builder
- Since:
- 4.0.0
-
keybind
@Contract("_ -> new") static @NonNull KeybindComponent keybind(@NonNull Consumer<? super KeybindComponent.Builder> consumer)Creates a keybind component by applying configuration fromconsumer
.- Parameters:
consumer
- the builder configurator- Returns:
- the keybind component
- Since:
- 4.0.0
-
keybind
@Contract(value="_ -> new", pure=true) static @NonNull KeybindComponent keybind(@NonNull String keybind)Creates a keybind component with a keybind.- Parameters:
keybind
- the keybind- Returns:
- the keybind component
- Since:
- 4.0.0
-
keybind
@Contract(value="_, _ -> new", pure=true) static @NonNull KeybindComponent keybind(@NonNull String keybind, @NonNull Style style)Creates a keybind component with a keybind and styling.- Parameters:
keybind
- the keybindstyle
- the style- Returns:
- the keybind component
- Since:
- 4.0.0
-
keybind
@Contract(value="_, _ -> new", pure=true) static @NonNull KeybindComponent keybind(@NonNull String keybind, @Nullable TextColor color)Creates a keybind component with a keybind, and optional color.- Parameters:
keybind
- the keybindcolor
- the color- Returns:
- the keybind component
- Since:
- 4.0.0
-
keybind
@Contract(value="_, _, _ -> new", pure=true) static @NonNull KeybindComponent keybind(@NonNull String keybind, @Nullable TextColor color, TextDecoration @NonNull ... decorations)Creates a keybind component with a keybind, and optional color and decorations.- Parameters:
keybind
- the keybindcolor
- the colordecorations
- the decorations- Returns:
- the keybind component
- Since:
- 4.0.0
-
keybind
@Contract(value="_, _, _ -> new", pure=true) static @NonNull KeybindComponent keybind(@NonNull String keybind, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)Creates a keybind component with a keybind, and optional color and decorations.- Parameters:
keybind
- the keybindcolor
- the colordecorations
- the decorations- Returns:
- the keybind component
- Since:
- 4.0.0
-
score
Creates a score component builder.- Returns:
- a builder
- Since:
- 4.0.0
-
score
@Contract("_ -> new") static @NonNull ScoreComponent score(@NonNull Consumer<? super ScoreComponent.Builder> consumer)Creates a score component by applying configuration fromconsumer
.- Parameters:
consumer
- the builder configurator- Returns:
- a score component
- Since:
- 4.0.0
-
score
@Contract(value="_, _ -> new", pure=true) static @NonNull ScoreComponent score(@NonNull String name, @NonNull String objective)Creates a score component with a name and objective.- Parameters:
name
- the score nameobjective
- the score objective- Returns:
- a score component
- Since:
- 4.0.0
-
score
@Contract(value="_, _, _ -> new", pure=true) @Deprecated static @NonNull ScoreComponent score(@NonNull String name, @NonNull String objective, @Nullable String value)Deprecated.since 4.7.0, not for removal, with no replacement. Thevalue
field is no longer supported in 1.16.5.Creates a score component with a name, objective, and optional value.- Parameters:
name
- the score nameobjective
- the score objectivevalue
- the value- Returns:
- a score component
- Since:
- 4.0.0
-
selector
Creates a selector component builder.- Returns:
- a builder
- Since:
- 4.0.0
-
selector
@Contract("_ -> new") static @NonNull SelectorComponent selector(@NonNull Consumer<? super SelectorComponent.Builder> consumer)Creates a selector component by applying configuration fromconsumer
.- Parameters:
consumer
- the builder configurator- Returns:
- a selector component
- Since:
- 4.0.0
-
selector
@Contract(value="_ -> new", pure=true) static @NonNull SelectorComponent selector(@NonNull String pattern)Creates a selector component with a pattern.- Parameters:
pattern
- the selector pattern- Returns:
- a selector component
- Since:
- 4.0.0
-
storageNBT
Creates an storage NBT component builder.- Returns:
- a builder
- Since:
- 4.0.0
-
storageNBT
@Contract("_ -> new") static @NonNull StorageNBTComponent storageNBT(@NonNull Consumer<? super StorageNBTComponent.Builder> consumer)Creates a storage NBT component by applying configuration fromconsumer
.- Parameters:
consumer
- the builder configurator- Returns:
- a storage NBT component
- Since:
- 4.0.0
-
storageNBT
@Contract(value="_, _ -> new", pure=true) static @NonNull StorageNBTComponent storageNBT(@NonNull String nbtPath, @NonNull net.kyori.adventure.key.Key storage)Creates a storage NBT component with a path and an storage ID.- Parameters:
nbtPath
- the nbt pathstorage
- the identifier of the storage- Returns:
- a storage NBT component
- Since:
- 4.0.0
-
storageNBT
@Contract(value="_, _, _ -> new", pure=true) static @NonNull StorageNBTComponent storageNBT(@NonNull String nbtPath, boolean interpret, @NonNull net.kyori.adventure.key.Key storage)Creates a storage NBT component with a path and an storage ID.- Parameters:
nbtPath
- the nbt pathinterpret
- whether to interpretstorage
- the identifier of the storage- Returns:
- a storage NBT component
- Since:
- 4.0.0
-
text
Creates a text component builder.- Returns:
- a builder
- Since:
- 4.0.0
-
text
@Contract("_ -> new") static @NonNull TextComponent text(@NonNull Consumer<? super TextComponent.Builder> consumer)Creates a text component by applying configuration fromconsumer
.- Parameters:
consumer
- the builder configurator- Returns:
- the text component
- Since:
- 4.0.0
-
text
Creates a text component with content.- Parameters:
content
- the plain text content- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(@NonNull String content, @NonNull Style style)Creates a text component with content and styling.- Parameters:
content
- the plain text contentstyle
- the style- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(@NonNull String content, @Nullable TextColor color)Creates a text component with content, and optional color.- Parameters:
content
- the plain text contentcolor
- the color- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(@NonNull String content, @Nullable TextColor color, TextDecoration @NonNull ... decorations)Creates a text component with content, and optional color and decorations.- Parameters:
content
- the plain text contentcolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(@NonNull String content, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)Creates a text component with content, and optional color and decorations.- Parameters:
content
- the plain text contentcolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
Creates a text component with the content ofString.valueOf(boolean)
.- Parameters:
value
- the boolean value- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(boolean value, @NonNull Style style)Creates a text component with the content ofString.valueOf(boolean)
and styling.- Parameters:
value
- the boolean valuestyle
- the style- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(boolean value, @Nullable TextColor color)Creates a text component with the content ofString.valueOf(boolean)
, and optional color.- Parameters:
value
- the boolean valuecolor
- the color- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(boolean value, @Nullable TextColor color, TextDecoration @NonNull ... decorations)Creates a text component with the content ofString.valueOf(boolean)
, and optional color and decorations.- Parameters:
value
- the boolean valuecolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(boolean value, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)Creates a text component with the content ofString.valueOf(boolean)
, and optional color and decorations.- Parameters:
value
- the boolean valuecolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
Creates a text component with the content ofString.valueOf(char)
.- Parameters:
value
- the char value- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(char value, @NonNull Style style)Creates a text component with the content ofString.valueOf(char)
and styling.- Parameters:
value
- the char valuestyle
- the style- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(char value, @Nullable TextColor color)Creates a text component with the content ofString.valueOf(char)
, and optional color.- Parameters:
value
- the char valuecolor
- the color- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(char value, @Nullable TextColor color, TextDecoration @NonNull ... decorations)Creates a text component with the content ofString.valueOf(char)
, and optional color and decorations.- Parameters:
value
- the char valuecolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(char value, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)Creates a text component with the content ofString.valueOf(char)
, and optional color and decorations.- Parameters:
value
- the char valuecolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
Creates a text component with the content ofString.valueOf(double)
.- Parameters:
value
- the double value- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(double value, @NonNull Style style)Creates a text component with the content ofString.valueOf(double)
and styling.- Parameters:
value
- the double valuestyle
- the style- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(double value, @Nullable TextColor color)Creates a text component with the content ofString.valueOf(double)
, and optional color.- Parameters:
value
- the double valuecolor
- the color- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(double value, @Nullable TextColor color, TextDecoration @NonNull ... decorations)Creates a text component with the content ofString.valueOf(double)
, and optional color and decorations.- Parameters:
value
- the double valuecolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(double value, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)Creates a text component with the content ofString.valueOf(double)
, and optional color and decorations.- Parameters:
value
- the double valuecolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
Creates a text component with the content ofString.valueOf(float)
.- Parameters:
value
- the float value- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(float value, @NonNull Style style)Creates a text component with the content ofString.valueOf(float)
and styling.- Parameters:
value
- the float valuestyle
- the style- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(float value, @Nullable TextColor color)Creates a text component with the content ofString.valueOf(float)
, and optional color.- Parameters:
value
- the float valuecolor
- the color- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(float value, @Nullable TextColor color, TextDecoration @NonNull ... decorations)Creates a text component with the content ofString.valueOf(float)
, and optional color and decorations.- Parameters:
value
- the float valuecolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(float value, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)Creates a text component with the content ofString.valueOf(float)
, and optional color and decorations.- Parameters:
value
- the float valuecolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
Creates a text component with the content ofString.valueOf(int)
.- Parameters:
value
- the int value- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(int value, @NonNull Style style)Creates a text component with the content ofString.valueOf(int)
and styling.- Parameters:
value
- the int valuestyle
- the style- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(int value, @Nullable TextColor color)Creates a text component with the content ofString.valueOf(int)
, and optional color.- Parameters:
value
- the int valuecolor
- the color- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(int value, @Nullable TextColor color, TextDecoration @NonNull ... decorations)Creates a text component with the content ofString.valueOf(int)
, and optional color and decorations.- Parameters:
value
- the int valuecolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(int value, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)Creates a text component with the content ofString.valueOf(int)
, and optional color and decorations.- Parameters:
value
- the int valuecolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
Creates a text component with the content ofString.valueOf(long)
.- Parameters:
value
- the long value- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(long value, @NonNull Style style)Creates a text component with the content ofString.valueOf(long)
and styling.- Parameters:
value
- the long valuestyle
- the style- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _ -> new", pure=true) static @NonNull TextComponent text(long value, @Nullable TextColor color)Creates a text component with the content ofString.valueOf(long)
, and optional color.- Parameters:
value
- the long valuecolor
- the color- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(long value, @Nullable TextColor color, TextDecoration @NonNull ... decorations)Creates a text component with the content ofString.valueOf(long)
, and optional color and decorations.- Parameters:
value
- the long valuecolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
text
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TextComponent text(long value, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)Creates a text component with the content ofString.valueOf(long)
, and optional color and decorations.- Parameters:
value
- the long valuecolor
- the colordecorations
- the decorations- Returns:
- a text component
- Since:
- 4.0.0
-
translatable
Creates a translatable component builder.- Returns:
- a builder
- Since:
- 4.0.0
-
translatable
@Contract("_ -> new") static @NonNull TranslatableComponent translatable(@NonNull Consumer<? super TranslatableComponent.Builder> consumer)Creates a translatable component by applying configuration fromconsumer
.- Parameters:
consumer
- the builder configurator- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_ -> new", pure=true) static @NonNull TranslatableComponent translatable(@NonNull String key)Creates a translatable component with a translation key.- Parameters:
key
- the translation key- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_, _ -> new", pure=true) static @NonNull TranslatableComponent translatable(@NonNull String key, @NonNull Style style)Creates a translatable component with a translation key and styling.- Parameters:
key
- the translation keystyle
- the style- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_, _ -> new", pure=true) static @NonNull TranslatableComponent translatable(@NonNull String key, @Nullable TextColor color)Creates a translatable component with a translation key, and optional color.- Parameters:
key
- the translation keycolor
- the color- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TranslatableComponent translatable(@NonNull String key, @Nullable TextColor color, TextDecoration @NonNull ... decorations)Creates a translatable component with a translation key, and optional color and decorations.- Parameters:
key
- the translation keycolor
- the colordecorations
- the decorations- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TranslatableComponent translatable(@NonNull String key, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations)Creates a translatable component with a translation key, and optional color and decorations.- Parameters:
key
- the translation keycolor
- the colordecorations
- the decorations- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_, _ -> new", pure=true) static @NonNull TranslatableComponent translatable(@NonNull String key, @NonNull ComponentLike @NonNull ... args)Creates a translatable component with a translation key and arguments.- Parameters:
key
- the translation keyargs
- the translation arguments- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TranslatableComponent translatable(@NonNull String key, @NonNull Style style, @NonNull ComponentLike @NonNull ... args)Creates a translatable component with a translation key and styling.- Parameters:
key
- the translation keystyle
- the styleargs
- the translation arguments- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TranslatableComponent translatable(@NonNull String key, @Nullable TextColor color, @NonNull ComponentLike @NonNull ... args)Creates a translatable component with a translation key, arguments, and optional color.- Parameters:
key
- the translation keycolor
- the colorargs
- the translation arguments- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_, _, _, _ -> new", pure=true) static @NonNull TranslatableComponent translatable(@NonNull String key, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations, @NonNull ComponentLike @NonNull ... args)Creates a translatable component with a translation key, arguments, and optional color and decorations.- Parameters:
key
- the translation keycolor
- the colordecorations
- the decorationsargs
- the translation arguments- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_, _ -> new", pure=true) static @NonNull TranslatableComponent translatable(@NonNull String key, @NonNull List<? extends ComponentLike> args)Creates a translatable component with a translation key and arguments.- Parameters:
key
- the translation keyargs
- the translation arguments- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_, _, _ -> new", pure=true) static @NonNull TranslatableComponent translatable(@NonNull String key, @NonNull Style style, @NonNull List<? extends ComponentLike> args)Creates a translatable component with a translation key and styling.- Parameters:
key
- the translation keystyle
- the styleargs
- the translation arguments- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_, _, _ -> new", pure=true) static TranslatableComponent translatable(@NonNull String key, @Nullable TextColor color, @NonNull List<? extends ComponentLike> args)Creates a translatable component with a translation key, arguments, and optional color.- Parameters:
key
- the translation keycolor
- the colorargs
- the translation arguments- Returns:
- a translatable component
- Since:
- 4.0.0
-
translatable
@Contract(value="_, _, _, _ -> new", pure=true) static @NonNull TranslatableComponent translatable(@NonNull String key, @Nullable TextColor color, @NonNull Set<TextDecoration> decorations, @NonNull List<? extends ComponentLike> args)Creates a translatable component with a translation key, arguments, and optional color and decorations.- Parameters:
key
- the translation keycolor
- the colordecorations
- the decorationsargs
- the translation arguments- Returns:
- a translatable component
- Since:
- 4.0.0
-
children
Gets the unmodifiable list of children.- Returns:
- the unmodifiable list of children
- Since:
- 4.0.0
-
children
Sets the list of children.The contents of
children
will be copied.- Parameters:
children
- the children- Returns:
- a component with the children set
- Since:
- 4.0.0
-
contains
Checks if this component contains a component.- Parameters:
that
- the other component- Returns:
true
if this component contains the provided component,false
otherwise- Since:
- 4.0.0
-
detectCycle
Deprecated.for removal since 4.7.0, with no replacement - this method is not necessary due to the factComponent
s are immutablePrevents a cycle between this component and the provided component.- Parameters:
that
- the other component- Since:
- 4.0.0
-
append
Appends a component to this component.- Parameters:
component
- the component to append- Returns:
- a component with the component added
- Since:
- 4.0.0
-
append
Appends a component to this component.- Parameters:
component
- the component to append- Returns:
- a component with the component added
- Since:
- 4.0.0
-
append
Appends a component to this component.- Parameters:
builder
- the component to append- Returns:
- a component with the component added
- Since:
- 4.0.0
-
style
@NonNull Style style()Gets the style of this component.- Returns:
- the style of this component
- Since:
- 4.0.0
-
style
Sets the style of this component.- Parameters:
style
- the style- Returns:
- a component
- Since:
- 4.0.0
-
style
Sets the style of this component.- Parameters:
consumer
- the style consumer- Returns:
- a component
- Since:
- 4.0.0
-
style
@Contract(pure=true) default @NonNull Component style(@NonNull Consumer<Style.Builder> consumer, @NonNull Style.Merge.Strategy strategy)Sets the style of this component.- Parameters:
consumer
- the style consumerstrategy
- the merge strategy- Returns:
- a component
- Since:
- 4.0.0
-
style
Sets the style of this component.- Parameters:
style
- the style- Returns:
- a component
- Since:
- 4.0.0
-
mergeStyle
Merges from another style into this component's style.- Parameters:
that
- the other style- Returns:
- a component
- Since:
- 4.0.0
-
mergeStyle
@Contract(pure=true) default @NonNull Component mergeStyle(@NonNull Component that, @NonNull Style.Merge @NonNull ... merges)Merges from another style into this component's style.- Parameters:
that
- the other stylemerges
- the style parts to merge- Returns:
- a component
- Since:
- 4.0.0
-
mergeStyle
@Contract(pure=true) default @NonNull Component mergeStyle(@NonNull Component that, @NonNull Set<Style.Merge> merges)Merges from another style into this component's style.- Parameters:
that
- the other stylemerges
- the style parts to merge- Returns:
- a component
- Since:
- 4.0.0
-
color
Gets the color of this component.- Returns:
- the color of this component
- Since:
- 4.0.0
-
color
Sets the color of this component.- Parameters:
color
- the color- Returns:
- a component
- Since:
- 4.0.0
-
colorIfAbsent
Sets the color if there isn't one set already.- Parameters:
color
- the color- Returns:
- a component
- Since:
- 4.0.0
-
hasDecoration
Tests if this component has a decoration.- Parameters:
decoration
- the decoration- Returns:
true
if this component has the decoration,false
if this component does not have the decoration- Since:
- 4.0.0
-
decorate
Sets the state ofdecoration
toTextDecoration.State.TRUE
on this component.- Parameters:
decoration
- the decoration- Returns:
- a component
- Since:
- 4.0.0
-
decoration
Gets the state of a decoration on this component.- Parameters:
decoration
- the decoration- Returns:
TextDecoration.State.TRUE
if this component has the decoration,TextDecoration.State.FALSE
if this component does not have the decoration, andTextDecoration.State.NOT_SET
if not set- Since:
- 4.0.0
-
decoration
@Contract(pure=true) default @NonNull Component decoration(@NonNull TextDecoration decoration, boolean flag)Sets the state of a decoration on this component.- Parameters:
decoration
- the decorationflag
-true
if this component should have the decoration,false
if this component should not have the decoration- Returns:
- a component
- Since:
- 4.0.0
-
decoration
@Contract(pure=true) default @NonNull Component decoration(@NonNull TextDecoration decoration, @NonNull TextDecoration.State state)Sets the value of a decoration on this component.- 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:
- a component
- Since:
- 4.0.0
-
decorations
Gets a set of decorations this component has.- Returns:
- a set of decorations this component has
- Since:
- 4.0.0
-
decorations
@Contract(pure=true) default @NonNull Component decorations(@NonNull 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.
- Parameters:
decorations
- a set of default values- Returns:
- a component
- Since:
- 4.0.0
-
clickEvent
Gets the click event of this component.- Returns:
- the click event
- Since:
- 4.0.0
-
clickEvent
Sets the click event of this component.- Parameters:
event
- the click event- Returns:
- a component
- Since:
- 4.0.0
-
hoverEvent
Gets the hover event of this component.- Returns:
- the hover event
- Since:
- 4.0.0
-
hoverEvent
Sets the hover event of this component.- Parameters:
source
- the hover event source- Returns:
- a component
- Since:
- 4.0.0
-
insertion
Gets the string to be inserted when this component is shift-clicked.- Returns:
- the insertion string
- Since:
- 4.0.0
-
insertion
Sets the string to be inserted when this component is shift-clicked.- Parameters:
insertion
- the insertion string- Returns:
- a component
- Since:
- 4.0.0
-
hasStyling
default boolean hasStyling()Tests if this component has any styling.- Returns:
true
if this component has any styling,false
if this component does not have any styling- Since:
- 4.0.0
-
replaceText
@Contract(pure=true) @NonNull Component replaceText(@NonNull Consumer<TextReplacementConfig.Builder> configurer)Finds and replaces any text with this or childComponent
s using the configured options.- Parameters:
configurer
- the configurer- Returns:
- a modified copy of this component
- Since:
- 4.2.0
-
replaceText
Finds and replaces any text with this or childComponent
s using the provided options.- Parameters:
config
- the replacement config- Returns:
- a modified copy of this component
- Since:
- 4.2.0
-
replaceText
@Contract(pure=true) @Deprecated default @NonNull Component replaceText(@NonNull String search, @Nullable ComponentLike replacement)Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.Finds and replaces text within anyComponent
s using a string literal.- Parameters:
search
- a string literalreplacement
- aComponentLike
to replace each match- Returns:
- a modified copy of this component
- Since:
- 4.0.0
-
replaceText
@Contract(pure=true) @Deprecated default @NonNull Component replaceText(@NonNull Pattern pattern, @NonNull Function<TextComponent.Builder,@Nullable ComponentLike> replacement)Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.Finds and replaces text within anyTextComponent
s using a regex pattern.- Parameters:
pattern
- a regex patternreplacement
- a function to replace each match- Returns:
- a modified copy of this component
- Since:
- 4.0.0
-
replaceFirstText
@Contract(pure=true) @Deprecated default @NonNull Component replaceFirstText(@NonNull String search, @Nullable ComponentLike replacement)Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.Finds and replaces the first occurrence of text within anyComponent
s using a string literal.- Parameters:
search
- a string literalreplacement
- aComponentLike
to replace the first match- Returns:
- a modified copy of this component
- Since:
- 4.0.0
-
replaceFirstText
@Contract(pure=true) @Deprecated default @NonNull Component replaceFirstText(@NonNull Pattern pattern, @NonNull Function<TextComponent.Builder,@Nullable ComponentLike> replacement)Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.Finds and replaces the first occurrence of text within anyTextComponent
s using a regex pattern.- Parameters:
pattern
- a regex patternreplacement
- a function to replace the first match- Returns:
- a modified copy of this component
- Since:
- 4.0.0
-
replaceText
@Contract(pure=true) @Deprecated default @NonNull Component replaceText(@NonNull String search, @Nullable ComponentLike replacement, int numberOfReplacements)Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.Finds and replacesn
instances of text within anyTextComponent
s using a string literal.- Parameters:
search
- a string literalreplacement
- aComponentLike
to replace the first matchnumberOfReplacements
- the amount of matches that should be replaced- Returns:
- a modified copy of this component
- Since:
- 4.0.0
-
replaceText
@Contract(pure=true) @Deprecated default @NonNull Component replaceText(@NonNull Pattern pattern, @NonNull Function<TextComponent.Builder,@Nullable ComponentLike> replacement, int numberOfReplacements)Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.Finds and replacesn
instances of text within anyTextComponent
s using a regex pattern.- Parameters:
pattern
- a regex patternreplacement
- a function to replace each matchnumberOfReplacements
- the amount of matches that should be replaced- Returns:
- a modified copy of this component
- Since:
- 4.0.0
-
replaceText
@Contract(pure=true) @Deprecated default @NonNull Component replaceText(@NonNull String search, @Nullable ComponentLike replacement, @NonNull IntFunction2<PatternReplacementResult> fn)Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.Finds and replacesn
instances of text within anyTextComponent
s using a string literal.Utilises an
IntFunction2
to determine if each instance should be replaced.- Parameters:
search
- a string literalreplacement
- aComponentLike
to replace the first matchfn
- a function of (index, replaced) used to determine if matches should be replaced, where "replaced" is the number of successful replacements- Returns:
- a modified copy of this component
- Since:
- 4.0.0
-
replaceText
@Contract(pure=true) @Deprecated default @NonNull Component replaceText(@NonNull Pattern pattern, @NonNull Function<TextComponent.Builder,@Nullable ComponentLike> replacement, @NonNull IntFunction2<PatternReplacementResult> fn)Deprecated.for removal since 4.2.0, usereplaceText(Consumer)
orreplaceText(TextReplacementConfig)
instead.Finds and replaces text using a regex pattern.Utilises an
IntFunction2
to determine if each instance should be replaced.- Parameters:
pattern
- a regex patternreplacement
- a function to replace the first matchfn
- a function of (index, replaced) used to determine if matches should be replaced, where "replaced" is the number of successful replacements- Returns:
- a modified copy of this component
- 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
-
asHoverEvent
Description copied from interface:HoverEventSource
Creates a hover event with value derived from this object.The event value will be passed through the provided callback to allow transforming the original value of the event.
- Specified by:
asHoverEvent
in interfaceHoverEventSource<Component>
- Parameters:
op
- transformation on value- Returns:
- a hover event
-
Component
s are immutable