Enum Class TextFormat

java.lang.Object
java.lang.Enum<TextFormat>
cn.nukkit.utils.TextFormat
All Implemented Interfaces:
Serializable, Comparable<TextFormat>, Constable

public enum TextFormat extends Enum<TextFormat>
All supported formatting values for chat and console.
  • Enum Constant Details

    • BLACK

      public static final TextFormat BLACK
      Represents black.
    • DARK_BLUE

      public static final TextFormat DARK_BLUE
      Represents dark blue.
    • DARK_GREEN

      public static final TextFormat DARK_GREEN
      Represents dark green.
    • DARK_AQUA

      public static final TextFormat DARK_AQUA
      Represents dark blue (aqua).
    • DARK_RED

      public static final TextFormat DARK_RED
      Represents dark red.
    • DARK_PURPLE

      public static final TextFormat DARK_PURPLE
      Represents dark purple.
    • GOLD

      public static final TextFormat GOLD
      Represents gold.
    • GRAY

      public static final TextFormat GRAY
      Represents gray.
    • DARK_GRAY

      public static final TextFormat DARK_GRAY
      Represents dark gray.
    • BLUE

      public static final TextFormat BLUE
      Represents blue.
    • GREEN

      public static final TextFormat GREEN
      Represents green.
    • AQUA

      public static final TextFormat AQUA
      Represents aqua.
    • RED

      public static final TextFormat RED
      Represents red.
    • LIGHT_PURPLE

      public static final TextFormat LIGHT_PURPLE
      Represents light purple.
    • YELLOW

      public static final TextFormat YELLOW
      Represents yellow.
    • WHITE

      public static final TextFormat WHITE
      Represents white.
    • MINECOIN_GOLD

      public static final TextFormat MINECOIN_GOLD
      Represents minecoins gold.
    • MATERIAL_QUARTZ

      @PowerNukkitXOnly @Since("1.19.80-r3") public static final TextFormat MATERIAL_QUARTZ
      Represents material quartz.
    • MATERIAL_IRON

      @PowerNukkitXOnly @Since("1.19.80-r3") public static final TextFormat MATERIAL_IRON
      Represents material iron.
    • MATERIAL_NETHERITE

      @PowerNukkitXOnly @Since("1.19.80-r3") public static final TextFormat MATERIAL_NETHERITE
      Represents material netherite.
    • MATERIAL_REDSTONE

      @PowerNukkitXOnly @Since("1.19.80-r3") public static final TextFormat MATERIAL_REDSTONE
      Represents material redstone.
    • MATERIAL_COPPER

      @PowerNukkitXOnly @Since("1.19.80-r3") public static final TextFormat MATERIAL_COPPER
      Represents material copper.
    • MATERIAL_GOLD

      @PowerNukkitXOnly @Since("1.19.80-r3") public static final TextFormat MATERIAL_GOLD
      Represents material gold.
    • MATERIAL_EMERALD

      @PowerNukkitXOnly @Since("1.19.80-r3") public static final TextFormat MATERIAL_EMERALD
      Represents material emerald.
    • MATERIAL_DIAMOND

      @PowerNukkitXOnly @Since("1.19.80-r3") public static final TextFormat MATERIAL_DIAMOND
      Represents material diamond.
    • MATERIAL_LAPIS

      @PowerNukkitXOnly @Since("1.19.80-r3") public static final TextFormat MATERIAL_LAPIS
      Represents material lapis.
    • MATERIAL_AMETHYST

      @PowerNukkitXOnly @Since("1.19.80-r3") public static final TextFormat MATERIAL_AMETHYST
      Represents material amethyst.
    • OBFUSCATED

      public static final TextFormat OBFUSCATED
      Makes the text obfuscated.
    • BOLD

      public static final TextFormat 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 STRIKETHROUGH
      Deprecated.
      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 UNDERLINE
      Deprecated.
      Makes the text appear underlined.
    • ITALIC

      public static final TextFormat ITALIC
      Makes the text italic.
    • RESET

      public static final TextFormat RESET
      Resets all previous chat colors or formats.
  • Field Details

    • ESCAPE

      public static final char ESCAPE
      The 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

      public static TextFormat[] 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

      public static TextFormat valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • getByChar

      public static TextFormat getByChar(char code)
      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

      public static TextFormat getByChar(String code)
      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

      public static String clean(String input)
      Cleans the given message of all format codes.
      Parameters:
      input - String to clean.
      Returns:
      A copy of the input string, without any formatting.
    • clean

      public static String clean(String input, boolean recursive)
    • colorize

      public static String colorize(char altFormatChar, String textToTranslate)
      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

      public static String colorize(String textToTranslate)
      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

      public static String getLastColors(String input)
      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

      public String toString()
      Overrides:
      toString in class Enum<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.