Add translateAlternateColorCodes method
This commit is contained in:
parent
fbf3fc9795
commit
0d443603be
@ -139,4 +139,17 @@ public enum ChatColor
|
||||
|
||||
return STRIP_COLOR_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate)
|
||||
{
|
||||
char[] b = textToTranslate.toCharArray();
|
||||
for (int i = 0; i < b.length - 1; i++)
|
||||
{
|
||||
if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1)
|
||||
{
|
||||
b[i] = ChatColor.COLOR_CHAR;
|
||||
b[i+1] = Character.toLowerCase(b[i+1]);
|
||||
}
|
||||
}
|
||||
return new String(b);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user