fix npe in /myinfo

This commit is contained in:
speed 2020-07-18 19:51:17 -04:00 committed by GitHub
parent 4f276ec78e
commit 588a2f1eba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -591,14 +591,17 @@ public class FUtil
public static String colorize(String string) public static String colorize(String string)
{ {
Matcher matcher = Pattern.compile("&#[a-f0-9A-F]{6}").matcher(string); if (string != null)
while (matcher.find())
{ {
String code = matcher.group().replace("&", ""); Matcher matcher = Pattern.compile("&#[a-f0-9A-F]{6}").matcher(string);
string = string.replace("&" + code, net.md_5.bungee.api.ChatColor.of(code) + ""); while (matcher.find())
} {
String code = matcher.group().replace("&", "");
string = string.replace("&" + code, net.md_5.bungee.api.ChatColor.of(code) + "");
}
string = ChatColor.translateAlternateColorCodes('&', string); string = ChatColor.translateAlternateColorCodes('&', string);
}
return string; return string;
} }