Skip to content

Commit 304e675

Browse files
committed
Match terminal colors with String.contains()
1 parent 48529ab commit 304e675

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/main/java/com/laytonsmith/core/Static.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ public static void SendMessage(final MCCommandSender m, String msg, final Target
504504
m.sendMessage(msg);
505505
} else {
506506
msg = Static.MCToANSIColors(msg);
507-
if (msg.matches("(?sm).*\033.*")) {
507+
if (msg.contains("\033")) {
508508
//We have terminal colors, we need to reset them at the end
509509
msg += TermColors.reset();
510510
}

src/main/java/com/laytonsmith/core/functions/Cmdline.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public Boolean runAsync() {
8181
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
8282
String msg = Static.MCToANSIColors(args[0].val());
8383
StreamUtils.GetSystemOut().print(msg);
84-
if (msg.matches("(?m).*\033.*")) {
84+
if (msg.contains("\033")) {
8585
//We have color codes in it, we need to reset them
8686
StreamUtils.GetSystemOut().print(TermColors.reset());
8787
}
@@ -146,7 +146,7 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
146146
String msg = Static.MCToANSIColors(args[0].val());
147147
PrintStream se = StreamUtils.GetSystemErr();
148148
se.print(msg);
149-
if (msg.matches("(?m).*\033.*")) {
149+
if (msg.contains("\033")) {
150150
//We have color codes in it, we need to reset them
151151
se.print(TermColors.reset());
152152
}

src/main/java/com/laytonsmith/core/functions/Echoes.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public Construct exec(Target t, Environment env, Construct... args) throws Cance
6161
Static.SendMessage(env.getEnv(CommandHelperEnvironment.class).GetCommandSender(), b.toString(), t);
6262
} else {
6363
String mes = Static.MCToANSIColors(b.toString());
64-
if(mes.matches("(?m).*\033.*")){
64+
if(mes.contains("\033")){
6565
//We have terminal colors, we need to reset them at the end
6666
mes += TermColors.reset();
6767
}
@@ -133,7 +133,7 @@ public Construct exec(final Target t, Environment env, final Construct... args)
133133
Static.SendMessage(p, b.toString(), t);
134134
} else {
135135
String mes = Static.MCToANSIColors(b.toString());
136-
if(mes.matches("(?m).*\033.*")){
136+
if(mes.contains("\033")){
137137
//We have terminal colors, we need to reset them at the end
138138
mes += TermColors.reset();
139139
}
@@ -614,7 +614,7 @@ public Construct exec(Target t, Environment env, Construct... args) throws Cance
614614
prefix = Static.getBoolean(args[1]);
615615
}
616616
mes = (prefix?"CommandHelper: ":"") + Static.MCToANSIColors(mes);
617-
if(mes.matches("(?m).*\033.*")){
617+
if(mes.contains("\033")){
618618
//We have terminal colors, we need to reset them at the end
619619
mes += TermColors.reset();
620620
}

0 commit comments

Comments
 (0)