Enum Class EnumChatFormat

java.lang.Object
java.lang.Enum<EnumChatFormat>
me.neznamy.tab.api.chat.EnumChatFormat
All Implemented Interfaces:
Serializable, Comparable<EnumChatFormat>, Constable

public enum EnumChatFormat extends Enum<EnumChatFormat>
An enum containing all possible legacy color codes and magic codes. Also contains handy color-related methods.
  • Enum Constant Details

  • Field Details

    • VALUES

      public static final EnumChatFormat[] VALUES
      Creating a constant to avoid memory allocations on each request
    • COLOR_CHAR

      public static final char COLOR_CHAR
      The symbol minecraft uses to colorize text
      See Also:
    • COLOR_STRING

      public static final String COLOR_STRING
      The color symbol in form of a string
  • Method Details

    • values

      public static EnumChatFormat[] 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 EnumChatFormat 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
    • getRed

      public short getRed()
      Returns red value of this color code
      Returns:
      red value
    • getGreen

      public short getGreen()
      Returns green value of this color code
      Returns:
      green value
    • getBlue

      public short getBlue()
      Returns blue value of this color code
      Returns:
      blue value
    • getByChar

      public static EnumChatFormat getByChar(char c)
      Returns enum value based on provided character or null if character is not valid
      Parameters:
      c - color code character (0-9, a-f, k-o, r)
      Returns:
      instance from the character or null if character is not valid
    • lastColorsOf

      public static EnumChatFormat lastColorsOf(String string)
      Returns enum value of last colors used in given string. If it's null, empty or does not contain color codes, WHITE is returned.
      Parameters:
      string - string to check last colors of
      Returns:
      last used color code in given string or WHITE if nothing is found
    • getFormat

      public String getFormat()
      Returns color char followed by color's character
      Returns:
      color char followed by color's character
    • getCharacter

      public char getCharacter()
      Returns character representing this color
      Returns:
      character representing this color
    • getHexCode

      public String getHexCode()
      Returns hex code of this format, null if this is a magic code
      Returns:
      hex code of this format
    • fromRGBExact

      public static EnumChatFormat fromRGBExact(int red, int green, int blue)
      Returns enum value with exact red, green and blue values or null if no match was found
      Parameters:
      red - exact red value
      green - exact green value
      blue - exact blue value
      Returns:
      enum value or null if no such combination exists
    • color

      public static String color(String textToTranslate)
      Color translation method taken from bukkit, which converts '&' symbol into the actual color character if followed by a valid color character.
      Parameters:
      textToTranslate - text to replace color symbol in
      Returns:
      colorized string from provided text
    • decolor

      public static String decolor(String text)
      Turns back the color symbol into '&' symbol in provided text.
      Parameters:
      text - text to revert colors in
      Returns:
      reverted text
    • getLastColors

      public static String getLastColors(String input)
      Code taken from bukkit, which returns last color codes used in provided text.
      Parameters:
      input - text to get last colors from
      Returns:
      last colors used in provided text or empty string if nothing was found