Skip to content

Commit

Permalink
Explore RGB ANSI code regex to fix matching
Browse files Browse the repository at this point in the history
  • Loading branch information
Pieter12345 committed Mar 16, 2024
1 parent f528bed commit 65554a2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/com/laytonsmith/core/Static.java
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,8 @@ public static String MCToANSIColors(String mes) {
}

// Convert RGB color codes to ANSI RGB color codes. Note that Windows command prompt ignores this.
mes = Pattern.compile("(?i)§x(?:§([a-f0-9])){6}").matcher(mes).replaceAll((MatchResult res) -> {
mes = Pattern.compile("(?i)§x§([a-f0-9])§([a-f0-9])§([a-f0-9])§([a-f0-9])§([a-f0-9])§([a-f0-9])")
.matcher(mes).replaceAll((MatchResult res) -> {
int red = Integer.parseInt(res.group(1) + res.group(2), 16);
int green = Integer.parseInt(res.group(3) + res.group(4), 16);
int blue = Integer.parseInt(res.group(5) + res.group(6), 16);
Expand Down

0 comments on commit 65554a2

Please sign in to comment.