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.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Represents 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 minecoins gold.
    Makes the text obfuscated.
    Represents red.
    Resets all previous chat colors or formats.
    Makes a line appear through the text.
    Makes the text appear underlined.
    Represents white.
    Represents yellow.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    The special character which prefixes all format codes.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    clean(String input)
    Cleans the given message of all format codes.
    static String
    clean(String input, boolean recursive)
     
    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.
    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.
    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
    Gets the char value associated with this color
    static String
    Gets the chat color used at the end of the given input string.
    boolean
    Checks if this code is a color code as opposed to a format code.
    boolean
    Checks if this code is a format code as opposed to a color code.
     
    static TextFormat
    Returns the enum constant of this class with the specified name.
    static TextFormat[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • 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.
    • OBFUSCATED

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

      public static final TextFormat BOLD
      Makes the text bold.
    • STRIKETHROUGH

      public static final TextFormat STRIKETHROUGH
      Makes a line appear through the text.
    • UNDERLINE

      public static final TextFormat UNDERLINE
      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.