Class ChatUtils


  • public class ChatUtils
    extends Object
    Handles all color codes (formatting/removing) within strings.
    • Field Detail

      • COLOR_CHARS

        public static final List<Character> COLOR_CHARS
        List of all valid color characters
    • Constructor Detail

      • ChatUtils

        public ChatUtils()
    • Method Detail

      • applyColorCodes

        public static String applyColorCodes​(String string,
                                             boolean blockDarkColors)
        This will translate 6 character and 3 character hex codes and standard minecraft color codes to color.
        Parameters:
        string - The string to colorize.
        blockDarkColors - Whether or not to disallow colors that are too dark.
        Returns:
        Formatted string.
      • applyColorCodes

        public static String applyColorCodes​(String string)
        Apply color codes using applyColorCodes(String, boolean) and defaulting blockDarkColors to false.
        Parameters:
        string - The string to colorize.
        Returns:
        Formatted string.
      • removeColorCodes

        public static String removeColorCodes​(String string)
        Completely remove all color codes from a string. This will strip all standard codes and hex codes.
        Parameters:
        string - The string to remove colors from.
        Returns:
        Clean string.
      • getLuminescence

        public static double getLuminescence​(String color)
        Get luminescence of a formatted hex color.
        Parameters:
        color - The formatted hex string.
        Returns:
        Luminescence value 0-255.
      • getColorCodes

        public static String getColorCodes​(String string)
        Get only the color codes from a given string. This includes hex codes.
        Parameters:
        string - The string to remove color codes from.
        Returns:
        String of only color codes.