summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/util')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/util/ServerRestartUtil.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/util/ServerRestartUtil.java b/src/main/java/com/keuin/kbackupfabric/util/ServerRestartUtil.java
new file mode 100644
index 0000000..1642e5c
--- /dev/null
+++ b/src/main/java/com/keuin/kbackupfabric/util/ServerRestartUtil.java
@@ -0,0 +1,58 @@
+package com.keuin.kbackupfabric.util;
+
+public class ServerRestartUtil {
+
+ public static void forkAndRestart() {
+// Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
+// @Override
+// public void run() {
+// // Here we restart the minecraft server
+// StringBuilder cmd = new StringBuilder();
+// cmd.append(System.getProperty("java.home")).append(File.separator).append("bin").append(File.separator).append("java ");
+// for (String jvmArg : ManagementFactory.getRuntimeMXBean().getInputArguments()) {
+// cmd.append(jvmArg + " ");
+// }
+// cmd.append("-cp ").append(ManagementFactory.getRuntimeMXBean().getClassPath()).append(" ");
+// cmd.append(MinecraftServer.class.getName()).append(" ");
+// for (String arg : args) {
+// cmd.append(arg).append(" ");
+// }
+// Runtime.getRuntime().exec(cmd.toString());
+// System.exit(0);
+// }
+// }));
+ }
+
+ private static void startRestartThread() {
+// (new Thread(() -> {
+//
+//
+// // kill threads
+// Set<Thread> threads = Thread.getAllStackTraces().keySet();
+// Thread currentThread = Thread.currentThread();
+// for (Thread t : threads) {
+// if(t != currentThread && t.isAlive()) {
+// t.setUncaughtExceptionHandler((t1, e) -> {
+// // set empty handler
+// });
+// //t.interrupt();
+// try {
+// t.setDaemon(true);
+// } catch (Exception ignored) {
+// }
+//
+// t.stop();
+// }
+// }
+//
+// try {
+// Thread.sleep(5000);
+// } catch (InterruptedException ignored) {
+// }
+//
+// // restart Minecraft server
+// String[] args = new String[]{};
+// MinecraftServer.main(args);
+// })).start();
+ }
+}