EngineHub / CommandHelper

Rapid scripting and command aliases for Minecraft owners
https://methodscript.com
Other
119 stars 71 forks source link

Support MC RGB colors in conversion to ANSI color codes #1373

Open Pieter12345 opened 11 months ago

Pieter12345 commented 11 months ago

This adds conversion from MC RGB colors to ANSI color codes. The catch is that Windows command prompt does not show these colors, so it might still make sense to convert these to the nearest available ANSI colors. If you use Linux or Mac OS, could you test whether RGB color codes now work in cmdline mode and leave a comment with the result? Thanks!

PseudoKnight commented 8 months ago

You're using a non-capturing parentheses group, so we get this:

java.lang.IndexOutOfBoundsException: No group 2
        at java.base/java.util.regex.Matcher.group(Matcher.java:646)
        at com.laytonsmith.core.Static.lambda$MCToANSIColors$0(Static.java:1188)
        at java.base/java.util.regex.Matcher.replaceAll(Matcher.java:1256)
        at com.laytonsmith.core.Static.MCToANSIColors(Static.java:1187)
Pieter12345 commented 8 months ago

You're using a non-capturing parentheses group, so we get this:

java.lang.IndexOutOfBoundsException: No group 2
        at java.base/java.util.regex.Matcher.group(Matcher.java:646)
        at com.laytonsmith.core.Static.lambda$MCToANSIColors$0(Static.java:1188)
        at java.base/java.util.regex.Matcher.replaceAll(Matcher.java:1256)
        at com.laytonsmith.core.Static.MCToANSIColors(Static.java:1187)

I'm not using a non-capturing parenthesis group (see inner part of (?i)§x(?:§([a-f0-9])){6}), but it appears that it only matches the last out of the 6 matches. I will explode it into (?i)§x§([a-f0-9])§([a-f0-9])§([a-f0-9])§([a-f0-9])§([a-f0-9])§([a-f0-9]).