Interface Style
- All Superinterfaces:
Buildable<Style.Builder>, StyleGetter, StyleSetter<Style>
A style applies visual effects or extra functionality to
Components,
such as TextColors, 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 Key in this context represents the resource location
of the font in the same way as Sounds
- Since:
- 4.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA style builder.static enumA merge choice. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription@Nullable ClickEvent<?> Gets the click event.clickEvent(@Nullable ClickEvent<?> event) Sets the click event.@Nullable TextColorcolor()Gets the color.Sets the color.colorIfAbsent(@Nullable TextColor color) Sets the color if there isn't one set already.default Styledecorate(TextDecoration decoration) Sets the state ofdecorationtoTextDecoration.State.TRUEon this style.decoration(TextDecoration decoration) Gets the state of a decoration on this style.default Styledecoration(TextDecoration decoration, boolean flag) Sets the state of a decoration on this style.decoration(TextDecoration decoration, TextDecoration.State state) Sets the value of a decoration on this style.decorationIfAbsent(TextDecoration decoration, TextDecoration.State state) Sets the state of a decoration on this style tostateif the current state of the decoration isTextDecoration.State.NOT_SET.default @Unmodifiable Map<TextDecoration, TextDecoration.State> Gets a map of decorations this style has.decorations(Map<TextDecoration, TextDecoration.State> decorations) Sets decorations for this style using the specifieddecorationsmap.default Styleedit(Consumer<Style.Builder> consumer) Edits this style.default Styleedit(Consumer<Style.Builder> consumer, Style.Merge.Strategy strategy) Edits this style.static Styleempty()Gets an empty style.@Nullable Keyfont()Gets the font.Sets the font.default booleanhasDecoration(TextDecoration decoration) Tests if this style has a decoration.@Nullable HoverEvent<?> Gets the hover event.hoverEvent(@Nullable HoverEventSource<?> source) Sets the hover event.@Nullable StringGets the string to be inserted when this style is shift-clicked.Sets the string to be inserted when this style is shift-clicked.booleanisEmpty()Tests if this style is empty.default StyleMerges from another style into this style.default Stylemerge(Style that, Set<Style.Merge> merges) Merges from another style into this style.default Stylemerge(Style that, Style.Merge merge) Merges from another style into this style.default Stylemerge(Style that, Style.Merge... merges) Merges from another style into this style.default Stylemerge(Style that, Style.Merge.Strategy strategy) Merges from another style into this style.merge(Style that, Style.Merge.Strategy strategy, Set<Style.Merge> merges) Merges from another style into this style.default Stylemerge(Style that, Style.Merge.Strategy strategy, Style.Merge merge) Merges from another style into this style.default Stylemerge(Style that, Style.Merge.Strategy strategy, Style.Merge... merges) Merges from another style into this style.static Style.Builderstyle()Creates a builder.static Stylestyle(Iterable<? extends StyleBuilderApplicable> applicables) Creates a style withapplicablesapplied.static Stylestyle(Consumer<Style.Builder> consumer) Creates a style.static Stylestyle(@Nullable StyleBuilderApplicable... applicables) Creates a style withapplicablesapplied.static StyleCreates a style with color.static Stylestyle(@Nullable TextColor color, Set<TextDecoration> decorations) Creates a style with color and decorations.static Stylestyle(@Nullable TextColor color, TextDecoration... decorations) Creates a style with color and decorations.static Stylestyle(TextDecoration decoration) Creates a style with decoration.Create a builder from this style.Simplify this style to remove any information that is redundant.Methods inherited from interface StyleGetter
shadowColorMethods inherited from interface StyleSetter
decorate, decorations, shadowColor, shadowColorIfAbsent
-
Field Details
-
DEFAULT_FONT
-
-
Method Details
-
empty
-
style
-
style
Creates a style.- Parameters:
consumer- the builder consumer- Returns:
- a style
- Since:
- 4.0.0
-
style
-
style
Creates a style with decoration.- Parameters:
decoration- the decoration- Returns:
- a style
- Since:
- 4.0.0
-
style
Creates a style with color and decorations.- Parameters:
color- the styledecorations- the decorations- Returns:
- a style
- Since:
- 4.0.0
-
style
Creates a style with color and decorations.- Parameters:
color- the styledecorations- the decorations- Returns:
- a style
- Since:
- 4.0.0
-
style
Creates a style withapplicablesapplied.- Parameters:
applicables- the applicables- Returns:
- a style
- Since:
- 4.0.0
-
style
Creates a style withapplicablesapplied.- Parameters:
applicables- the applicables- Returns:
- a style
- Since:
- 4.0.0
-
edit
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
Edits this style.- Parameters:
consumer- the consumerstrategy- the merge strategy- Returns:
- a new style
- Since:
- 4.0.0
-
font
@Nullable Key font()Gets the font.- Specified by:
fontin interfaceStyleGetter- Returns:
- the font
- Since:
- 4.0.0
- Since Minecraft:
- 1.16
-
font
Sets the font.- Specified by:
fontin interfaceStyleSetter<Style>- Parameters:
font- the font- Returns:
- a style
- Since:
- 4.0.0
- Since Minecraft:
- 1.16
-
color
@Nullable TextColor color()Gets the color.- Specified by:
colorin interfaceStyleGetter- Returns:
- the color
- Since:
- 4.0.0
-
color
Sets the color.- Specified by:
colorin interfaceStyleSetter<Style>- Parameters:
color- the color- Returns:
- a style
- Since:
- 4.0.0
-
colorIfAbsent
Sets the color if there isn't one set already.- Specified by:
colorIfAbsentin interfaceStyleSetter<Style>- Parameters:
color- the color- Returns:
- this builder
- Since:
- 4.0.0
-
hasDecoration
Tests if this style has a decoration.- Specified by:
hasDecorationin interfaceStyleGetter- Parameters:
decoration- the decoration- Returns:
trueif this style has the decoration,falseif this style does not have the decoration- Since:
- 4.0.0
-
decoration
Gets the state of a decoration on this style.- Specified by:
decorationin interfaceStyleGetter- Parameters:
decoration- the decoration- Returns:
TextDecoration.State.TRUEif this style has the decoration,TextDecoration.State.FALSEif this style does not have the decoration, andTextDecoration.State.NOT_SETif not set- Since:
- 4.0.0
-
decorate
Sets the state ofdecorationtoTextDecoration.State.TRUEon this style.- Specified by:
decoratein interfaceStyleSetter<Style>- Parameters:
decoration- the decoration- Returns:
- a style
- Since:
- 4.0.0
-
decoration
Sets the state of a decoration on this style.- Specified by:
decorationin interfaceStyleSetter<Style>- Parameters:
decoration- the decorationflag-trueif this style should have the decoration,falseif this style should not have the decoration- Returns:
- a style
- Since:
- 4.0.0
-
decoration
Sets the value of a decoration on this style.- Specified by:
decorationin interfaceStyleSetter<Style>- Parameters:
decoration- the decorationstate-TextDecoration.State.TRUEif this style should have the decoration,TextDecoration.State.FALSEif this style should not have the decoration, andTextDecoration.State.NOT_SETif the decoration should not have a set value- Returns:
- a style
- Since:
- 4.0.0
-
decorationIfAbsent
Sets the state of a decoration on this style tostateif the current state of the decoration isTextDecoration.State.NOT_SET.- Specified by:
decorationIfAbsentin interfaceStyleSetter<Style>- Parameters:
decoration- the decorationstate- the state- Returns:
- a style
- Since:
- 4.12.0
-
decorations
Gets a map of decorations this style has.- Specified by:
decorationsin interfaceStyleGetter- Returns:
- a map of decorations this style has
- Since:
- 4.0.0
-
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.
- Specified by:
decorationsin interfaceStyleSetter<Style>- Parameters:
decorations- the decorations- Returns:
- a style
- Since:
- 4.0.0
-
clickEvent
@Nullable ClickEvent<?> clickEvent()Gets the click event.- Specified by:
clickEventin interfaceStyleGetter- Returns:
- the click event
- Since:
- 4.0.0
-
clickEvent
Sets the click event.- Specified by:
clickEventin interfaceStyleSetter<Style>- Parameters:
event- the click event- Returns:
- a style
- Since:
- 4.0.0
-
hoverEvent
@Nullable HoverEvent<?> hoverEvent()Gets the hover event.- Specified by:
hoverEventin interfaceStyleGetter- Returns:
- the hover event
- Since:
- 4.0.0
-
hoverEvent
Sets the hover event.- Specified by:
hoverEventin interfaceStyleSetter<Style>- Parameters:
source- the hover event source- Returns:
- a style
- Since:
- 4.0.0
-
insertion
@Nullable String insertion()Gets the string to be inserted when this style is shift-clicked.- Specified by:
insertionin interfaceStyleGetter- Returns:
- the insertion string
- Since:
- 4.0.0
-
insertion
Sets the string to be inserted when this style is shift-clicked.- Specified by:
insertionin interfaceStyleSetter<Style>- Parameters:
insertion- the insertion string- Returns:
- a style
- Since:
- 4.0.0
-
merge
-
merge
Merges from another style into this style.- Parameters:
that- the other stylestrategy- the merge strategy- Returns:
- a style
- Since:
- 4.0.0
-
merge
Merges from another style into this style.- Parameters:
that- the other stylemerge- the part to merge- Returns:
- a style
- Since:
- 4.0.0
-
merge
Merges from another style into this style.- Parameters:
that- the other stylestrategy- the merge strategymerge- the part to merge- Returns:
- a style
- Since:
- 4.0.0
-
merge
Merges from another style into this style.- Parameters:
that- the other stylemerges- the parts to merge- Returns:
- a style
- Since:
- 4.0.0
-
merge
Merges from another style into this style.- Parameters:
that- the other stylestrategy- the merge strategymerges- the parts to merge- Returns:
- a style
- Since:
- 4.0.0
-
merge
Merges from another style into this style.- Parameters:
that- the other stylemerges- the parts to merge- Returns:
- a style
- Since:
- 4.0.0
-
merge
Merges from another style into this style.- Parameters:
that- the other stylestrategy- the merge strategymerges- the parts to merge- Returns:
- a style
- Since:
- 4.0.0
-
unmerge
-
isEmpty
boolean isEmpty()Tests if this style is empty.- Returns:
trueif this style is empty,falseif this style is not empty- Since:
- 4.0.0
-
toBuilder
Style.Builder toBuilder()Create a builder from this style.- Specified by:
toBuilderin interfaceBuildable<Style.Builder>- Returns:
- a builder
- Since:
- 4.0.0
-