mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-22 18:09:06 +00:00
Allow support for #ffffff hex color codes
This commit is contained in:
parent
3d13056eea
commit
25116631c5
@ -434,6 +434,8 @@ public class Format {
|
||||
allFormated = chatColorPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = chatHexColorPattern.matcher(allFormated).replaceAll("\u00A7$1");
|
||||
allFormated = allFormated.replaceAll("%", "\\%");
|
||||
|
||||
allFormated = convertHexColorCodeStringToBukkitColorCodeString(allFormated);
|
||||
return allFormated;
|
||||
}
|
||||
|
||||
@ -517,6 +519,20 @@ public class Format {
|
||||
return bukkitColorCode.toString();
|
||||
}
|
||||
|
||||
public static String convertHexColorCodeStringToBukkitColorCodeString(String string) {
|
||||
Pattern pattern = Pattern.compile("(#[0-9a-fA-F]{6})");
|
||||
Matcher matcher = pattern.matcher(string);
|
||||
while(matcher.find()) {
|
||||
int indexStart = matcher.start();
|
||||
int indexEnd = matcher.end();
|
||||
String hexColor = string.substring(indexStart, indexEnd);
|
||||
String bukkitColor = convertHexColorCodeToBukkitColorCode(hexColor);
|
||||
string = string.replaceAll(hexColor, bukkitColor);
|
||||
matcher.reset(string);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public static String escapeAllRegex(String input) {
|
||||
return input.replace("[", "\\[").replace("]", "\\]").replace("{", "\\{").replace("}", "\\}").replace("(", "\\(").replace(")", "\\)").replace("|", "\\|").replace("+", "\\+").replace("*", "\\*");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user