forked from SteamWar/SteamWar
Format code
This commit is contained in:
@@ -195,26 +195,28 @@ public class Persistent {
|
||||
CommandManager commandManager = proxy.getCommandManager();
|
||||
for (String alias : commandManager.getAliases()) {
|
||||
CommandMeta meta = commandManager.getCommandMeta(alias);
|
||||
if (meta != null && meta.getPlugin() == plugin)
|
||||
if (meta != null && meta.getPlugin() == plugin) {
|
||||
commandManager.unregister(meta);
|
||||
}
|
||||
}
|
||||
|
||||
proxy.getEventManager().unregisterListeners(plugin);
|
||||
proxy.getScheduler().tasksByPlugin(plugin).forEach(ScheduledTask::cancel);
|
||||
|
||||
container.getExecutorService().shutdown();
|
||||
if (!container.getExecutorService().awaitTermination(100, TimeUnit.MILLISECONDS))
|
||||
if (!container.getExecutorService().awaitTermination(100, TimeUnit.MILLISECONDS)) {
|
||||
logger.log(Level.WARNING, "ExecutorService termination took longer than 100ms, continuing.");
|
||||
}
|
||||
|
||||
for (Thread thread : Thread.getAllStackTraces().keySet()) {
|
||||
if (thread.getClass().getClassLoader() != classLoader)
|
||||
continue;
|
||||
if (thread.getClass().getClassLoader() != classLoader) continue;
|
||||
|
||||
thread.interrupt();
|
||||
thread.join(100);
|
||||
|
||||
if (thread.isAlive())
|
||||
if (thread.isAlive()) {
|
||||
logger.log(Level.WARNING, "Could not stop thread %s of plugin %s. Still running".formatted(thread.getName(), container.getDescription().getId()));
|
||||
}
|
||||
}
|
||||
|
||||
//TODO close all log handlers
|
||||
|
||||
@@ -65,8 +65,7 @@ public class Subserver {
|
||||
public static Subserver getSubserver(Player p) {
|
||||
synchronized (serverList) {
|
||||
for (int i = serverList.size() - 1; i >= 0; i--) {
|
||||
if (serverList.get(i).onServer(p))
|
||||
return serverList.get(i);
|
||||
if (serverList.get(i).onServer(p)) return serverList.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -142,8 +141,9 @@ public class Subserver {
|
||||
public void stop() {
|
||||
try {
|
||||
long pid = process.pid();
|
||||
if (checkpoint)
|
||||
if (checkpoint) {
|
||||
pid = process.children().findAny().map(ProcessHandle::pid).orElse(pid);
|
||||
}
|
||||
|
||||
Runtime.getRuntime().exec(new String[]{"kill", "-SIGUSR1", Long.toString(pid)});
|
||||
} catch (IOException e) {
|
||||
@@ -156,8 +156,7 @@ public class Subserver {
|
||||
process.destroyForcibly();
|
||||
}
|
||||
|
||||
if (thread.isAlive())
|
||||
thread.join();
|
||||
if (thread.isAlive()) thread.join();
|
||||
} catch (InterruptedException e) {
|
||||
logger.log(Level.SEVERE, "Subserver stop interrupted!", e);
|
||||
Thread.currentThread().interrupt();
|
||||
@@ -186,8 +185,9 @@ public class Subserver {
|
||||
started = test.test(line);
|
||||
}
|
||||
|
||||
if (line == null)
|
||||
if (line == null) {
|
||||
throw new IOException(serverName + " did not start correctly!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,18 +225,18 @@ public class Subserver {
|
||||
} else {
|
||||
sendProgress(0);
|
||||
start(process.getInputStream(), line -> {
|
||||
if (line.contains("Loading libraries, please wait"))
|
||||
if (line.contains("Loading libraries, please wait")) {
|
||||
sendProgress(2);
|
||||
else if (line.contains("Starting Minecraft server on"))
|
||||
} else if (line.contains("Starting Minecraft server on")) {
|
||||
sendProgress(5);
|
||||
else if (line.contains("Preparing start region"))
|
||||
} else if (line.contains("Preparing start region")) {
|
||||
sendProgress(8);
|
||||
}
|
||||
return line.contains("Done (");
|
||||
});
|
||||
}
|
||||
|
||||
if (!started)
|
||||
return;
|
||||
if (!started) return;
|
||||
|
||||
sendProgress(10);
|
||||
for (Player cachedPlayer : cachedPlayers) {
|
||||
@@ -253,8 +253,7 @@ public class Subserver {
|
||||
} finally {
|
||||
unregister();
|
||||
shutdownCallback.run();
|
||||
if (ex != null)
|
||||
failureCallback.accept(ex);
|
||||
if (ex != null) failureCallback.accept(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user