Package net.kyori.adventure.text.format
Interface Style
- 
- All Superinterfaces:
- Buildable<Style,Style.Builder>,- net.kyori.examination.Examinable
 
 @NonExtendable public interface Style extends Buildable<Style,Style.Builder>, net.kyori.examination.Examinable A style applies visual effects or extra functionality toComponents, such asTextColors,TextDecorations,ClickEvents etc.Some examples of valid styles: Style myStyle = Style.style(ClickEvent.openUrl(url), NamedTextColor.RED, TextDecoration.BOLD); Style yourStyle = Style.style(TextColor.color(20, 30, 40), HoverEvent.showText(Component.text("Wow!")); Style ourStyle = Style.style().color(NamedTextColor.WHITE).build();A note about fonts: the Keyin this context represents the resource location of the font in the same way asSounds- Since:
- 4.0.0
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Interface Description static interfaceStyle.BuilderA style builder.static classStyle.MergeA merge choice.
 - 
Field SummaryFields Modifier and Type Field Description static KeyDEFAULT_FONTThe default font.
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description @Nullable ClickEventclickEvent()Gets the click event.@NotNull StyleclickEvent(@Nullable ClickEvent event)Sets the click event.@Nullable TextColorcolor()Gets the color.@NotNull Stylecolor(@Nullable TextColor color)Sets the color.@NotNull StylecolorIfAbsent(@Nullable TextColor color)Sets the color if there isn't one set already.default @NotNull Styledecorate(@NotNull TextDecoration decoration)Sets the state ofdecorationtoTextDecoration.State.TRUEon this style.@NotNull TextDecoration.Statedecoration(@NotNull TextDecoration decoration)Gets the state of a decoration on this style.default @NotNull Styledecoration(@NotNull TextDecoration decoration, boolean flag)Sets the state of a decoration on this style.@NotNull Styledecoration(@NotNull TextDecoration decoration, @NotNull TextDecoration.State state)Sets the value of a decoration on this style.@Unmodifiable @NotNull Map<TextDecoration,TextDecoration.State>decorations()Gets a map of decorations this style has.@NotNull Styledecorations(@NotNull Map<TextDecoration,TextDecoration.State> decorations)Sets decorations for this style using the specifieddecorationsmap.default @NotNull Styleedit(@NotNull Consumer<Style.Builder> consumer)Edits this style.default @NotNull Styleedit(@NotNull Consumer<Style.Builder> consumer, @NotNull Style.Merge.Strategy strategy)Edits this style.static @NotNull Styleempty()Gets an empty style.@Nullable Keyfont()Gets the font.@NotNull Stylefont(@Nullable Key font)Sets the font.default booleanhasDecoration(@NotNull TextDecoration decoration)Tests if this style has a decoration.@Nullable HoverEvent<?>hoverEvent()Gets the hover event.@NotNull StylehoverEvent(@Nullable HoverEventSource<?> source)Sets the hover event.@Nullable Stringinsertion()Gets the string to be inserted when this style is shift-clicked.@NotNull Styleinsertion(@Nullable String insertion)Sets the string to be inserted when this style is shift-clicked.booleanisEmpty()Tests if this style is empty.default @NotNull Stylemerge(@NotNull Style that)Merges from another style into this style.default @NotNull Stylemerge(@NotNull Style that, @NotNull Set<Style.Merge> merges)Merges from another style into this style.default @NotNull Stylemerge(@NotNull Style that, @NotNull Style.Merge merge)Merges from another style into this style.default @NotNull Stylemerge(@NotNull Style that, @NotNull Style.Merge.Strategy strategy)Merges from another style into this style.@NotNull Stylemerge(@NotNull Style that, @NotNull Style.Merge.Strategy strategy, @NotNull Set<Style.Merge> merges)Merges from another style into this style.default @NotNull Stylemerge(@NotNull Style that, @NotNull Style.Merge.Strategy strategy, @NotNull Style.Merge merge)Merges from another style into this style.default @NotNull Stylemerge(@NotNull Style that, @NotNull Style.Merge.Strategy strategy, @NotNull Style.Merge @NotNull ... merges)Merges from another style into this style.default @NotNull Stylemerge(@NotNull Style that, @NotNull Style.Merge @NotNull ... merges)Merges from another style into this style.static @NotNull Style.Builderstyle()Creates a builder.static @NotNull Stylestyle(@NotNull Iterable<? extends StyleBuilderApplicable> applicables)Creates a style withapplicablesapplied.static @NotNull Stylestyle(@NotNull Consumer<Style.Builder> consumer)Creates a style.static @NotNull Stylestyle(@NotNull TextDecoration decoration)Creates a style with decoration.static @NotNull Stylestyle(@Nullable TextColor color)Creates a style with color.static @NotNull Stylestyle(@Nullable TextColor color, Set<TextDecoration> decorations)Creates a style with color and decorations.static @NotNull Stylestyle(@Nullable TextColor color, TextDecoration @NotNull ... decorations)Creates a style with color and decorations.static @NotNull Stylestyle(StyleBuilderApplicable @NotNull ... applicables)Creates a style withapplicablesapplied.@NotNull Style.BuildertoBuilder()Create a builder from this style.
 
- 
- 
- 
Field Detail- 
DEFAULT_FONTstatic final Key DEFAULT_FONT The default font.- Since:
- 4.0.0
- Since Minecraft:
- 1.16
 
 
- 
 - 
Method Detail- 
empty@NotNull static @NotNull Style empty() Gets an empty style.- Returns:
- empty style
- Since:
- 4.0.0
 
 - 
style@NotNull static @NotNull Style.Builder style() Creates a builder.- Returns:
- a builder
- Since:
- 4.0.0
 
 - 
style@NotNull static @NotNull Style style(@NotNull @NotNull Consumer<Style.Builder> consumer) Creates a style.- Parameters:
- consumer- the builder consumer
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
style@NotNull static @NotNull Style style(@Nullable @Nullable TextColor color) Creates a style with color.- Parameters:
- color- the style
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
style@NotNull static @NotNull Style style(@NotNull @NotNull TextDecoration decoration) Creates a style with decoration.- Parameters:
- decoration- the decoration
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
style@NotNull static @NotNull Style style(@Nullable @Nullable TextColor color, TextDecoration @NotNull ... decorations) Creates a style with color and decorations.- Parameters:
- color- the style
- decorations- the decorations
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
style@NotNull static @NotNull Style style(@Nullable @Nullable TextColor color, Set<TextDecoration> decorations) Creates a style with color and decorations.- Parameters:
- color- the style
- decorations- the decorations
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
style@NotNull static @NotNull Style style(StyleBuilderApplicable @NotNull ... applicables) Creates a style withapplicablesapplied.- Parameters:
- applicables- the applicables
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
style@NotNull static @NotNull Style style(@NotNull @NotNull Iterable<? extends StyleBuilderApplicable> applicables) Creates a style withapplicablesapplied.- Parameters:
- applicables- the applicables
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
edit@NotNull default @NotNull Style edit(@NotNull @NotNull Consumer<Style.Builder> consumer) Edits this style.The old style will be merge into the new style before consumeris called.- Parameters:
- consumer- the consumer
- Returns:
- a new style
- Since:
- 4.0.0
 
 - 
edit@NotNull default @NotNull Style edit(@NotNull @NotNull Consumer<Style.Builder> consumer, @NotNull Style.Merge.Strategy strategy) Edits this style.- Parameters:
- consumer- the consumer
- strategy- the merge strategy
- Returns:
- a new style
- Since:
- 4.0.0
 
 - 
font@Nullable @Nullable Key font() Gets the font.- Returns:
- the font
- Since:
- 4.0.0
- Since Minecraft:
- 1.16
 
 - 
font@NotNull @NotNull Style font(@Nullable @Nullable Key font) Sets the font.- Parameters:
- font- the font
- Returns:
- a style
- Since:
- 4.0.0
- Since Minecraft:
- 1.16
 
 - 
color@Nullable @Nullable TextColor color() Gets the color.- Returns:
- the color
- Since:
- 4.0.0
 
 - 
color@NotNull @NotNull Style color(@Nullable @Nullable TextColor color) Sets the color.- Parameters:
- color- the color
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
colorIfAbsent@NotNull @NotNull Style colorIfAbsent(@Nullable @Nullable TextColor color) Sets the color if there isn't one set already.- Parameters:
- color- the color
- Returns:
- this builder
- Since:
- 4.0.0
 
 - 
hasDecorationdefault boolean hasDecoration(@NotNull @NotNull TextDecoration decoration)Tests if this style has a decoration.- Parameters:
- decoration- the decoration
- Returns:
- trueif this style has the decoration,- falseif this style does not have the decoration
- Since:
- 4.0.0
 
 - 
decoration@NotNull TextDecoration.State decoration(@NotNull @NotNull TextDecoration decoration) Gets the state of a decoration on this style.- Parameters:
- decoration- the decoration
- Returns:
- TextDecoration.State.TRUEif this style has the decoration,- TextDecoration.State.FALSEif this style does not have the decoration, and- TextDecoration.State.NOT_SETif not set
- Since:
- 4.0.0
 
 - 
decorate@NotNull default @NotNull Style decorate(@NotNull @NotNull TextDecoration decoration) Sets the state ofdecorationtoTextDecoration.State.TRUEon this style.- Parameters:
- decoration- the decoration
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
decoration@NotNull default @NotNull Style decoration(@NotNull @NotNull TextDecoration decoration, boolean flag) Sets the state of a decoration on this style.- Parameters:
- decoration- the decoration
- flag-- trueif this style should have the decoration,- falseif this style should not have the decoration
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
decoration@NotNull @NotNull Style decoration(@NotNull @NotNull TextDecoration decoration, @NotNull TextDecoration.State state) Sets the value of a decoration on this style.- Parameters:
- decoration- the decoration
- state-- TextDecoration.State.TRUEif this style should have the decoration,- TextDecoration.State.FALSEif this style should not have the decoration, and- TextDecoration.State.NOT_SETif the decoration should not have a set value
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
decorations@NotNull @Unmodifiable @NotNull Map<TextDecoration,TextDecoration.State> decorations() Gets a map of decorations this style has.- Returns:
- a set of decorations this style has
- Since:
- 4.0.0
 
 - 
decorations@NotNull @NotNull Style decorations(@NotNull @NotNull Map<TextDecoration,TextDecoration.State> decorations) Sets decorations for this style using the specifieddecorationsmap.If a given decoration does not have a value explicitly set, the value of that particular decoration is not changed. - Parameters:
- decorations- the decorations
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
clickEvent@Nullable @Nullable ClickEvent clickEvent() Gets the click event.- Returns:
- the click event
- Since:
- 4.0.0
 
 - 
clickEvent@NotNull @NotNull Style clickEvent(@Nullable @Nullable ClickEvent event) Sets the click event.- Parameters:
- event- the click event
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
hoverEvent@Nullable @Nullable HoverEvent<?> hoverEvent() Gets the hover event.- Returns:
- the hover event
- Since:
- 4.0.0
 
 - 
hoverEvent@NotNull @NotNull Style hoverEvent(@Nullable @Nullable HoverEventSource<?> source) Sets the hover event.- Parameters:
- source- the hover event source
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
insertion@Nullable @Nullable String insertion() Gets the string to be inserted when this style is shift-clicked.- Returns:
- the insertion string
- Since:
- 4.0.0
 
 - 
insertion@NotNull @NotNull Style insertion(@Nullable @Nullable String insertion) Sets the string to be inserted when this style is shift-clicked.- Parameters:
- insertion- the insertion string
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
merge@NotNull default @NotNull Style merge(@NotNull @NotNull Style that) Merges from another style into this style.- Parameters:
- that- the other style
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
merge@NotNull default @NotNull Style merge(@NotNull @NotNull Style that, @NotNull Style.Merge.Strategy strategy) Merges from another style into this style.- Parameters:
- that- the other style
- strategy- the merge strategy
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
merge@NotNull default @NotNull Style merge(@NotNull @NotNull Style that, @NotNull @NotNull Style.Merge merge) Merges from another style into this style.- Parameters:
- that- the other style
- merge- the part to merge
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
merge@NotNull default @NotNull Style merge(@NotNull @NotNull Style that, @NotNull Style.Merge.Strategy strategy, @NotNull @NotNull Style.Merge merge) Merges from another style into this style.- Parameters:
- that- the other style
- strategy- the merge strategy
- merge- the part to merge
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
merge@NotNull default @NotNull Style merge(@NotNull @NotNull Style that, @NotNull @NotNull Style.Merge @NotNull ... merges) Merges from another style into this style.- Parameters:
- that- the other style
- merges- the parts to merge
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
merge@NotNull default @NotNull Style merge(@NotNull @NotNull Style that, @NotNull Style.Merge.Strategy strategy, @NotNull @NotNull Style.Merge @NotNull ... merges) Merges from another style into this style.- Parameters:
- that- the other style
- strategy- the merge strategy
- merges- the parts to merge
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
merge@NotNull default @NotNull Style merge(@NotNull @NotNull Style that, @NotNull @NotNull Set<Style.Merge> merges) Merges from another style into this style.- Parameters:
- that- the other style
- merges- the parts to merge
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
merge@NotNull @NotNull Style merge(@NotNull @NotNull Style that, @NotNull Style.Merge.Strategy strategy, @NotNull @NotNull Set<Style.Merge> merges) Merges from another style into this style.- Parameters:
- that- the other style
- strategy- the merge strategy
- merges- the parts to merge
- Returns:
- a style
- Since:
- 4.0.0
 
 - 
isEmptyboolean isEmpty() Tests if this style is empty.- Returns:
- trueif this style is empty,- falseif this style is not empty
- Since:
- 4.0.0
 
 - 
toBuilder@NotNull @NotNull Style.Builder toBuilder() Create a builder from this style.- Specified by:
- toBuilderin interface- Buildable<Style,Style.Builder>
- Returns:
- a builder
 
 
- 
 
-