Package cn.nukkit.utils
Enum Class TextFormat
- All Implemented Interfaces:
Serializable
,Comparable<TextFormat>
,Constable
All supported formatting values for chat and console.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionRepresents aqua.Represents black.Represents blue.Makes the text bold.Represents dark blue (aqua).Represents dark blue.Represents dark gray.Represents dark green.Represents dark purple.Represents dark red.Represents gold.Represents gray.Represents green.Makes the text italic.Represents light purple.Represents material amethyst.Represents material copper.Represents material diamond.Represents material emerald.Represents material gold.Represents material iron.Represents material lapis.Represents material netherite.Represents material quartz.Represents material redstone.Represents minecoins gold.Makes the text obfuscated.Represents red.Resets all previous chat colors or formats.Deprecated.Deprecated.Represents white.Represents yellow. -
Field Summary
Modifier and TypeFieldDescriptionstatic final char
The special character which prefixes all format codes. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Cleans the given message of all format codes.static String
static String
Translates a string using an alternate format code character into a string that uses the internal TextFormat.ESCAPE format code character.static String
Translates a string, using an ampersand (&) as an alternate format code character, into a string that uses the internal TextFormat.ESCAPE format code character.static TextFormat
getByChar
(char code) Gets the TextFormat represented by the specified format code.static TextFormat
Gets the TextFormat represented by the specified format code.char
getChar()
Gets the char value associated with this colorstatic String
getLastColors
(String input) Gets the chat color used at the end of the given input string.boolean
isColor()
Checks if this code is a color code as opposed to a format code.boolean
isFormat()
Checks if this code is a format code as opposed to a color code.toString()
static TextFormat
Returns the enum constant of this class with the specified name.static TextFormat[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
BLACK
Represents black. -
DARK_BLUE
Represents dark blue. -
DARK_GREEN
Represents dark green. -
DARK_AQUA
Represents dark blue (aqua). -
DARK_RED
Represents dark red. -
DARK_PURPLE
Represents dark purple. -
GOLD
Represents gold. -
GRAY
Represents gray. -
DARK_GRAY
Represents dark gray. -
BLUE
Represents blue. -
GREEN
Represents green. -
AQUA
Represents aqua. -
RED
Represents red. -
LIGHT_PURPLE
Represents light purple. -
YELLOW
Represents yellow. -
WHITE
Represents white. -
MINECOIN_GOLD
Represents minecoins gold. -
MATERIAL_QUARTZ
Represents material quartz. -
MATERIAL_IRON
Represents material iron. -
MATERIAL_NETHERITE
Represents material netherite. -
MATERIAL_REDSTONE
Represents material redstone. -
MATERIAL_COPPER
Represents material copper. -
MATERIAL_GOLD
Represents material gold. -
MATERIAL_EMERALD
Represents material emerald. -
MATERIAL_DIAMOND
Represents material diamond. -
MATERIAL_LAPIS
Represents material lapis. -
MATERIAL_AMETHYST
Represents material amethyst. -
OBFUSCATED
Makes the text obfuscated. -
BOLD
Makes the text bold. -
STRIKETHROUGH
@Deprecated @DeprecationDetails(since="1.19.80-r3", reason="Code STRIKETHROUGH has been replaced by MATERIAL_REDSTONE in Minecraft version 1.19.81", replaceWith="TextFormat.MATERIAL_REDSTONE") public static final TextFormat STRIKETHROUGHDeprecated.Makes a line appear through the text. -
UNDERLINE
@Deprecated @DeprecationDetails(since="1.19.80-r3", reason="Code UNDERLINE has been replaced by MATERIAL_COPPER in Minecraft version 1.19.81", replaceWith="TextFormat.MATERIAL_COPPER") public static final TextFormat UNDERLINEDeprecated.Makes the text appear underlined. -
ITALIC
Makes the text italic. -
RESET
Resets all previous chat colors or formats.
-
-
Field Details
-
ESCAPE
public static final char ESCAPEThe special character which prefixes all format codes. Use this if you need to dynamically convert format codes from your custom format.- See Also:
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getByChar
Gets the TextFormat represented by the specified format code.- Parameters:
code
- Code to check- Returns:
- Associative
TextFormat
with the given code, or null if it doesn't exist
-
getByChar
Gets the TextFormat represented by the specified format code.- Parameters:
code
- Code to check- Returns:
- Associative
TextFormat
with the given code, or null if it doesn't exist
-
clean
Cleans the given message of all format codes.- Parameters:
input
- String to clean.- Returns:
- A copy of the input string, without any formatting.
-
clean
-
colorize
Translates a string using an alternate format code character into a string that uses the internal TextFormat.ESCAPE format code character. The alternate format code character will only be replaced if it is immediately followed by 0-9, A-G, a-g, K-O, k-o, R or r.- Parameters:
altFormatChar
- The alternate format code character to replace. Ex: &textToTranslate
- Text containing the alternate format code character.- Returns:
- Text containing the TextFormat.ESCAPE format code character.
-
colorize
Translates a string, using an ampersand (&) as an alternate format code character, into a string that uses the internal TextFormat.ESCAPE format code character. The alternate format code character will only be replaced if it is immediately followed by 0-9, A-G, a-g, K-O, k-o, R or r.- Parameters:
textToTranslate
- Text containing the alternate format code character.- Returns:
- Text containing the TextFormat.ESCAPE format code character.
-
getLastColors
Gets the chat color used at the end of the given input string.- Parameters:
input
- Input string to retrieve the colors from.- Returns:
- Any remaining chat color to pass onto the next line.
-
getChar
public char getChar()Gets the char value associated with this color- Returns:
- A char value of this color code
-
toString
- Overrides:
toString
in classEnum<TextFormat>
-
isFormat
public boolean isFormat()Checks if this code is a format code as opposed to a color code. -
isColor
public boolean isColor()Checks if this code is a color code as opposed to a format code.
-