Skip to content

Commit 24c225a

Browse files
committed
#371 Add hex support to messages.yml
1 parent 36ac55f commit 24c225a

File tree

1 file changed

+4
-11
lines changed
  • src/main/java/dev/espi/protectionstones

1 file changed

+4
-11
lines changed

src/main/java/dev/espi/protectionstones/PSL.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -516,21 +516,14 @@ private static void messageUpgrades(PSL psl, YamlConfiguration yml) {
516516
}
517517
}
518518

519-
// match all %#123abc#% format for hex
520-
private static final Pattern hexPatternLong = Pattern.compile("(?<!\\\\\\\\)(%#[a-fA-F0-9]{8}%)"),
521-
hexPatternShort = Pattern.compile("(?<!\\\\\\\\)(%#[a-fA-F0-9]{6}%)");
519+
// match all &#123abc format for hex
520+
private static final Pattern hexPattern = Pattern.compile("(?<!\\\\\\\\)(&#[a-fA-F0-9]{6})");
522521

523522
private static String applyInGameColours(String msg) {
524523

525-
Matcher matcher = hexPatternLong.matcher(msg);
524+
Matcher matcher = hexPattern.matcher(msg);
526525
while (matcher.find()) {
527-
String color = msg.substring(matcher.start() + 1, matcher.end() - 1);
528-
msg = msg.replace(msg.substring(matcher.start(), matcher.end()), "" + net.md_5.bungee.api.ChatColor.of(color));
529-
}
530-
531-
matcher = hexPatternShort.matcher(msg);
532-
while (matcher.find()) {
533-
String color = msg.substring(matcher.start() + 1, matcher.end() - 1);
526+
String color = msg.substring(matcher.start() + 1, matcher.end());
534527
msg = msg.replace(msg.substring(matcher.start(), matcher.end()), "" + net.md_5.bungee.api.ChatColor.of(color));
535528
}
536529

0 commit comments

Comments
 (0)