Zond: коррекция цветных надписей
This commit is contained in:
@@ -34,8 +34,12 @@ public class ZondCommandHandler implements CommandHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String zondColored(String string) {
|
private static String zondColored(String string) {
|
||||||
|
return zondColored(string, Ansi.Color.CYAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String zondColored(String string, Ansi.Color color) {
|
||||||
return Ansi.ansi().bg(Ansi.Color.WHITE).fg(Ansi.Color.RED).a("[Zond]")
|
return Ansi.ansi().bg(Ansi.Color.WHITE).fg(Ansi.Color.RED).a("[Zond]")
|
||||||
.reset().fg(Ansi.Color.RED).a(' ').a(string)
|
.reset().fgBright(color).a(' ').a(string)
|
||||||
.reset().toString();
|
.reset().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,9 +47,7 @@ public class ZondCommandHandler implements CommandHandler {
|
|||||||
threadTicker = new Thread(() -> {
|
threadTicker = new Thread(() -> {
|
||||||
int sec = 0;
|
int sec = 0;
|
||||||
while (!Thread.currentThread().isInterrupted() && flagTicker) {
|
while (!Thread.currentThread().isInterrupted() && flagTicker) {
|
||||||
Shell.getInstance().getOutput().println(zondColored(
|
Shell.getInstance().getOutput().println(zondColored("Tick "+(sec++)+" sec"));
|
||||||
Ansi.ansi().fg(Ansi.Color.CYAN).a("Tick "+(sec++)+" sec").toString()
|
|
||||||
));
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -133,15 +135,15 @@ public class ZondCommandHandler implements CommandHandler {
|
|||||||
Runnable callback;
|
Runnable callback;
|
||||||
if (flagTicker) {
|
if (flagTicker) {
|
||||||
callback = () -> {
|
callback = () -> {
|
||||||
Shell.getInstance().getOutput().println(zondColored("[!] Process - zobie?"));
|
Shell.getInstance().getOutput().println(zondColored("[!] Process - zobie?", Ansi.Color.RED));
|
||||||
};
|
};
|
||||||
|
|
||||||
buildThreadTicker();
|
buildThreadTicker();
|
||||||
threadTicker.start();
|
threadTicker.start();
|
||||||
} else {
|
} else {
|
||||||
callback = () -> {
|
callback = () -> {
|
||||||
Shell.getInstance().getOutput().println(zondColored("[!] Process - zobie?"));
|
Shell.getInstance().getOutput().println(zondColored("[!] Process - zobie?", Ansi.Color.RED));
|
||||||
Shell.getInstance().getOutput().println(zondColored("[!] Force shutdown process."));
|
Shell.getInstance().getOutput().println(zondColored("[!] Force shutdown process.", Ansi.Color.RED));
|
||||||
flagForceRestartProcess = true;
|
flagForceRestartProcess = true;
|
||||||
killProcess();
|
killProcess();
|
||||||
};
|
};
|
||||||
@@ -151,7 +153,7 @@ public class ZondCommandHandler implements CommandHandler {
|
|||||||
} catch (ExecuteException e) {
|
} catch (ExecuteException e) {
|
||||||
code = e.getExitValue();
|
code = e.getExitValue();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Shell.getInstance().getOutput().println(zondColored("[!] Exception message: " + e.getMessage()));
|
Shell.getInstance().getOutput().println(zondColored("[!] Exception message: " + e.getMessage(), Ansi.Color.RED));
|
||||||
code = -99;
|
code = -99;
|
||||||
}
|
}
|
||||||
long currTime = System.currentTimeMillis()/1000;
|
long currTime = System.currentTimeMillis()/1000;
|
||||||
@@ -159,7 +161,7 @@ public class ZondCommandHandler implements CommandHandler {
|
|||||||
server.shutdown();
|
server.shutdown();
|
||||||
pingMonitor.stop();
|
pingMonitor.stop();
|
||||||
server = null;
|
server = null;
|
||||||
Shell.getInstance().getOutput().println(zondColored("[i] Process finished. Code: " + code));
|
Shell.getInstance().getOutput().println(zondColored("[i] Process finished. Code: " + code, Ansi.Color.RED));
|
||||||
|
|
||||||
if (pingMonitor.isCorrectShutdown()) {
|
if (pingMonitor.isCorrectShutdown()) {
|
||||||
flagForceRestartProcess = false;
|
flagForceRestartProcess = false;
|
||||||
@@ -169,16 +171,16 @@ public class ZondCommandHandler implements CommandHandler {
|
|||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (currTime <= deadTime && !flagManualKill) {
|
if (currTime <= deadTime && !flagManualKill) {
|
||||||
Shell.getInstance().getOutput().println(zondColored("[!] Premature end process."));
|
Shell.getInstance().getOutput().println(zondColored("[!] Premature end process.", Ansi.Color.RED));
|
||||||
_try++;
|
_try++;
|
||||||
if (_try < 2) {
|
if (_try < 2) {
|
||||||
Shell.getInstance().getOutput().println(zondColored("[!] Try start process again..."));
|
Shell.getInstance().getOutput().println(zondColored("[!] Try start process again...", Ansi.Color.RED));
|
||||||
}
|
}
|
||||||
} else if (flagForceRestartProcess) {
|
} else if (flagForceRestartProcess) {
|
||||||
_try = 0;
|
_try = 0;
|
||||||
flagForceRestartProcess = false;
|
flagForceRestartProcess = false;
|
||||||
} else if (code != 0 && code != -99 && !flagManualKill) {
|
} else if (code != 0 && code != -99 && !flagManualKill) {
|
||||||
Shell.getInstance().getOutput().println(zondColored("[!] Try start process again..."));
|
Shell.getInstance().getOutput().println(zondColored("[!] Try start process again...", Ansi.Color.RED));
|
||||||
_try = 0;
|
_try = 0;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@@ -187,7 +189,7 @@ public class ZondCommandHandler implements CommandHandler {
|
|||||||
} while (_try < 2);
|
} while (_try < 2);
|
||||||
|
|
||||||
if (_try == 2) {
|
if (_try == 2) {
|
||||||
Shell.getInstance().getOutput().println(zondColored("[!] Discovered the problem when starting the process"));
|
Shell.getInstance().getOutput().println(zondColored("[!] Discovered the problem when starting the process", Ansi.Color.RED));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
threadExec = new Thread(task, "Zond Exec");
|
threadExec = new Thread(task, "Zond Exec");
|
||||||
|
|||||||
Reference in New Issue
Block a user