A little more documentation.

This commit is contained in:
Andrew Steinborn
2018-07-31 16:22:21 -04:00
parent bbf861d3bc
commit 8b1e1f20cf
2 changed files with 18 additions and 3 deletions

View File

@@ -8,11 +8,15 @@ import java.util.regex.Pattern;
* LegacyChatColorUtils contains utilities for handling legacy Minecraft color codes. Generally, you should prefer
* JSON-based components, but for convenience Velocity provides a limited set of tools to handle Minecraft color codes.
*/
public enum LegacyChatColorUtils {
;
public class LegacyChatColorUtils {
private LegacyChatColorUtils() {
throw new AssertionError();
}
/**
* Represents the legacy Minecraft format character, the section symbol.
*/
public static final char FORMAT_CHAR = '\u00a7';
private static final Pattern CHAT_COLOR_MATCHER = Pattern.compile("(?i)" + Character.toString(FORMAT_CHAR) + "[0-9A-FL-OR]");
/**
* Translates a string with Minecraft color codes prefixed with a different character than the section symbol into
@@ -44,6 +48,11 @@ public enum LegacyChatColorUtils {
return new String(textChars);
}
/**
* A regex that matches all Minecraft color codes and removes them.
*/
private static final Pattern CHAT_COLOR_MATCHER = Pattern.compile("(?i)" + Character.toString(FORMAT_CHAR) + "[0-9A-FL-OR]");
/**
* Removes all Minecraft color codes from the string.
* @param text the text to remove color codes from