mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-09 18:08:20 +01:00
Color HEX support for ConfigUtil (#1379)
* Added HEX support to ConfigUtil
This commit is contained in:
parent
d8c48a5f5a
commit
0db18eade8
@ -14,6 +14,8 @@
|
|||||||
package me.blackvein.quests.util;
|
package me.blackvein.quests.util;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -188,6 +190,17 @@ public class ConfigUtil {
|
|||||||
parsed = parsed.replace("<reset>", ChatColor.RESET.toString());
|
parsed = parsed.replace("<reset>", ChatColor.RESET.toString());
|
||||||
parsed = parsed.replace("<br>", "\n");
|
parsed = parsed.replace("<br>", "\n");
|
||||||
parsed = ChatColor.translateAlternateColorCodes('&', parsed);
|
parsed = ChatColor.translateAlternateColorCodes('&', parsed);
|
||||||
|
|
||||||
|
Matcher matcher = Pattern.compile("(?i)<#([0-9A-F]{6})>").matcher(parsed);
|
||||||
|
while (matcher.find()) {
|
||||||
|
StringBuilder hex = new StringBuilder();
|
||||||
|
hex.append(ChatColor.COLOR_CHAR + "x");
|
||||||
|
char[] chars = matcher.group(1).toCharArray();
|
||||||
|
for (int index = 0; index < chars.length; index++) {
|
||||||
|
hex.append(ChatColor.COLOR_CHAR).append(Character.toLowerCase(chars[index]));
|
||||||
|
}
|
||||||
|
parsed = parsed.replace(matcher.group(), hex.toString());
|
||||||
|
}
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user