Zond: цветной текст
This commit is contained in:
@@ -12,6 +12,7 @@ import org.apache.commons.exec.CommandLine;
|
||||
import org.apache.commons.exec.ExecuteException;
|
||||
import org.apache.commons.exec.ExecuteWatchdog;
|
||||
import org.apache.commons.exec.Executor;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -30,6 +31,12 @@ public class ZondCommandHandler implements CommandHandler {
|
||||
this.proxyStdIn = proxyStdIn;
|
||||
}
|
||||
|
||||
private static String zondColored(String string) {
|
||||
return Ansi.ansi().bg(Ansi.Color.WHITE).fg(Ansi.Color.RED).a("[Zond]")
|
||||
.reset().fg(Ansi.Color.RED).a(' ').a(string)
|
||||
.reset().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(String commandLine) {
|
||||
if (commandLine.startsWith(":")) {
|
||||
@@ -54,10 +61,10 @@ public class ZondCommandHandler implements CommandHandler {
|
||||
} else if (line.equalsIgnoreCase("connect")) {
|
||||
Connector.getInstance().startReconnect();
|
||||
} else if (line.equalsIgnoreCase("disconnect")) {
|
||||
Shell.getInstance().getOutput().println("Disconnect");
|
||||
Shell.getInstance().getOutput().println(zondColored("Disconnect"));
|
||||
Connector.getInstance().shutdown();
|
||||
} else if (line.equalsIgnoreCase("reload")) {
|
||||
Shell.getInstance().getOutput().println("Reload config");
|
||||
Shell.getInstance().getOutput().println(zondColored("Reload config"));
|
||||
try {
|
||||
Config.getInstance().load();
|
||||
} catch (IOException e) {
|
||||
@@ -104,8 +111,8 @@ public class ZondCommandHandler implements CommandHandler {
|
||||
|
||||
deadTime = (System.currentTimeMillis()/1000) + (delay*1000);
|
||||
pingMonitor.start(() -> {
|
||||
Shell.getInstance().getOutput().println("[!] Process - zobie?");
|
||||
Shell.getInstance().getOutput().println("[!] Force shutdown process.");
|
||||
Shell.getInstance().getOutput().println(zondColored("[!] Process - zobie?"));
|
||||
Shell.getInstance().getOutput().println(zondColored("[!] Force shutdown process."));
|
||||
flagForceRestartProcess = true;
|
||||
killProcess();
|
||||
});
|
||||
@@ -113,7 +120,7 @@ public class ZondCommandHandler implements CommandHandler {
|
||||
} catch (ExecuteException e) {
|
||||
code = e.getExitValue();
|
||||
} catch (IOException e) {
|
||||
Shell.getInstance().getOutput().println("[!] Exception message: " + e.getMessage());
|
||||
Shell.getInstance().getOutput().println(zondColored("[!] Exception message: " + e.getMessage()));
|
||||
code = -99;
|
||||
}
|
||||
long currTime = System.currentTimeMillis()/1000;
|
||||
@@ -121,7 +128,7 @@ public class ZondCommandHandler implements CommandHandler {
|
||||
server.shutdown();
|
||||
pingMonitor.stop();
|
||||
server = null;
|
||||
Shell.getInstance().getOutput().println("[i] Process finished. Code: " + code);
|
||||
Shell.getInstance().getOutput().println(zondColored("[i] Process finished. Code: " + code));
|
||||
|
||||
if (pingMonitor.isCorrectShutdown()) {
|
||||
flagForceRestartProcess = false;
|
||||
@@ -129,16 +136,16 @@ public class ZondCommandHandler implements CommandHandler {
|
||||
break;
|
||||
} else {
|
||||
if (currTime <= deadTime && !flagManualKill) {
|
||||
Shell.getInstance().getOutput().println("[!] Premature end process.");
|
||||
Shell.getInstance().getOutput().println(zondColored("[!] Premature end process."));
|
||||
_try++;
|
||||
if (_try < 2) {
|
||||
Shell.getInstance().getOutput().println("[!] Try start process again...");
|
||||
Shell.getInstance().getOutput().println(zondColored("[!] Try start process again..."));
|
||||
}
|
||||
} else if (flagForceRestartProcess) {
|
||||
_try = 0;
|
||||
flagForceRestartProcess = false;
|
||||
} else if (code != 0 && code != -99 && !flagManualKill) {
|
||||
Shell.getInstance().getOutput().println("[!] Try start process again...");
|
||||
Shell.getInstance().getOutput().println(zondColored("[!] Try start process again..."));
|
||||
_try = 0;
|
||||
} else {
|
||||
break;
|
||||
@@ -147,7 +154,7 @@ public class ZondCommandHandler implements CommandHandler {
|
||||
} while (_try < 2);
|
||||
|
||||
if (_try == 2) {
|
||||
Shell.getInstance().getOutput().println("[!] Discovered the problem when starting the process");
|
||||
Shell.getInstance().getOutput().println(zondColored("[!] Discovered the problem when starting the process"));
|
||||
}
|
||||
};
|
||||
threadExec = new Thread(task, "Zond Exec");
|
||||
|
||||
Reference in New Issue
Block a user