Package dev.majek.pc.chat
Class ChatUtils
- java.lang.Object
-
- dev.majek.pc.chat.ChatUtils
-
public class ChatUtils extends Object
Handles all color codes (formatting/removing) within strings.
-
-
Field Summary
Fields Modifier and Type Field Description static List<Character>
COLOR_CHARS
List of all valid color characters
-
Constructor Summary
Constructors Constructor Description ChatUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
applyColorCodes(String string)
Apply color codes usingapplyColorCodes(String, boolean)
and defaulting blockDarkColors to false.static String
applyColorCodes(String string, boolean blockDarkColors)
This will translate 6 character and 3 character hex codes and standard minecraft color codes to color.static String
getColorCodes(String string)
Get only the color codes from a given string.static double
getLuminescence(String color)
Get luminescence of a formatted hex color.static String
removeColorCodes(String string)
Completely remove all color codes from a string.
-
-
-
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 usingapplyColorCodes(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.
-
-