mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
Slower, but more correct
This commit is contained in:
parent
93378504ba
commit
fda23a1b47
@ -66,15 +66,11 @@ public class StringHelper {
|
||||
}
|
||||
|
||||
public static String parseColors(String parsed) {
|
||||
Matcher matcher = COLOR_MATCHER.matcher(parsed);
|
||||
if (!matcher.matches())
|
||||
return parsed;
|
||||
String replace = matcher.group(1) != null ? GROUP_1 : GROUP_2;
|
||||
return matcher.replaceAll(replace);
|
||||
Matcher matcher = COLOR_MATCHER.matcher(ChatColor.translateAlternateColorCodes('&', parsed));
|
||||
return matcher.replaceAll(GROUP);
|
||||
}
|
||||
|
||||
private static String GROUP_1 = ChatColor.COLOR_CHAR + "$1";
|
||||
private static String GROUP_2 = ChatColor.COLOR_CHAR + "$2";
|
||||
private static String GROUP = ChatColor.COLOR_CHAR + "$1";
|
||||
|
||||
public static String wrap(Object string) {
|
||||
return wrap(string, parseColors(Setting.MESSAGE_COLOUR.asString()));
|
||||
@ -97,7 +93,7 @@ public class StringHelper {
|
||||
String colors = "";
|
||||
for (ChatColor color : ChatColor.values())
|
||||
colors += color.getChar();
|
||||
COLOR_MATCHER = Pattern.compile("&([COLORS])|<([COLORS])>".replace("COLORS", colors),
|
||||
COLOR_MATCHER = Pattern.compile("\\<([COLORS])\\>".replace("COLORS", colors),
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user