Package net.kyori.adventure.text.format
Interface TextColor
- All Superinterfaces:
Comparable<TextColor>,ComponentBuilderApplicable,net.kyori.examination.Examinable,RGBLike,StyleBuilderApplicable,TextFormat
- All Known Implementing Classes:
NamedTextColor
public interface TextColor extends Comparable<TextColor>, net.kyori.examination.Examinable, RGBLike, StyleBuilderApplicable, TextFormat
A color which may be applied to a
Style.
The full range of hexadecimal colors are only supported in Minecraft: Java Edition 1.16 and above.
On older versions, platforms may downsample these to NamedTextColors.
This color does not include any alpha channel information.
- Since:
- 4.0.0
- See Also:
NamedTextColor
-
Method Summary
Modifier and Type Method Description default @NonNull StringasHexString()Gets the color, as a hex string.default @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) intblue()Get the blue component of the text colour.static @NonNull TextColorcolor(@org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int r, @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int g, @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int b)Create a new text colour with the red, green, and blue components individually.static @NonNull TextColorcolor(float r, float g, float b)Create a new color with the individual components as floats.static @NonNull TextColorcolor(int value)Creates a new text colour.static @NonNull TextColorcolor(RGBLike rgb)Creates a new text colour.default intcompareTo(TextColor that)default @NonNull Stream<? extends net.kyori.examination.ExaminableProperty>examinableProperties()static @Nullable TextColorfromCSSHexString(@NonNull String string)Create a color from a CSS hex string (#rrggbbor#rgb).static @Nullable TextColorfromHexString(@NonNull String string)Create a new color from a hex string.default @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) intgreen()Get the green component of the text colour.default @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) intred()Get the red component of the text colour.default voidstyleApply(@NonNull Style.Builder style)Applies tostyle.intvalue()The color, as an RGB value packed into an int.Methods inherited from interface net.kyori.examination.Examinable
examinableName, examineMethods inherited from interface net.kyori.adventure.text.format.StyleBuilderApplicable
componentBuilderApply
-
Method Details
-
color
Creates a new text colour.- Parameters:
value- the rgb value- Returns:
- a new text colour
- Since:
- 4.0.0
-
color
Creates a new text colour.- Parameters:
rgb- the rgb value- Returns:
- a new text colour
- Since:
- 4.0.0
-
color
static @NonNull TextColor color(@org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int r, @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int g, @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int b)Create a new text colour with the red, green, and blue components individually.- Parameters:
r- red, as a value from 0 to 255g- green, as a value from 0 to 255b- blue, as a value from 0 to 255- Returns:
- a new text colour
- Since:
- 4.0.0
-
color
Create a new color with the individual components as floats.- Parameters:
r- red, from [0, 1]g- green, within [0, 1]b- blue, within [0, 1]- Returns:
- a new text colour
- Since:
- 4.0.0
-
fromHexString
Create a new color from a hex string.- Parameters:
string- the hex string- Returns:
- a new text colour
- Since:
- 4.0.0
-
fromCSSHexString
Create a color from a CSS hex string (#rrggbbor#rgb).- Parameters:
string- the hex string- Returns:
- a new text colour
- Since:
- 4.0.0
-
value
int value()The color, as an RGB value packed into an int.- Returns:
- the value
- Since:
- 4.0.0
-
asHexString
Gets the color, as a hex string.- Returns:
- a hex string
- Since:
- 4.0.0
-
red
default @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int red()Get the red component of the text colour. -
green
default @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int green()Get the green component of the text colour. -
blue
default @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int blue()Get the blue component of the text colour. -
styleApply
Description copied from interface:StyleBuilderApplicableApplies tostyle.- Specified by:
styleApplyin interfaceStyleBuilderApplicable- Parameters:
style- the style builder
-
compareTo
- Specified by:
compareToin interfaceComparable<TextColor>
-
examinableProperties
- Specified by:
examinablePropertiesin interfacenet.kyori.examination.Examinable
-