use of net.glowstone.util.ShutdownMonitorThread in project Glowstone by GlowstoneMC.
the class GlowServer method shutdown.
/**
* Stops this server, sending the specified message to all players on their kick screen.
*
* @param message Message to send to all players as they are kicked
*/
public void shutdown(String message) {
// Just in case this gets called twice
if (isShuttingDown) {
return;
}
isShuttingDown = true;
ConsoleMessages.Info.SHUTDOWN.log();
// Disable plugins
pluginManager.clearPlugins();
// Kick all players (this saves their data too)
for (GlowPlayer player : new ArrayList<>(getRawOnlinePlayers())) {
player.kickPlayer(message, false);
}
// It may take a second or two for Netty to totally clean up
if (networkServer != null) {
networkServer.shutdown();
}
if (queryServer != null) {
queryServer.shutdown();
}
if (rconServer != null) {
rconServer.shutdown();
}
// Save worlds
for (World world : getWorlds()) {
ConsoleMessages.Info.SAVE.log(world.getName());
unloadWorld(world, true);
}
// Stop scheduler and console
scheduler.stop();
consoleManager.stop();
// Wait for a while and terminate any rogue threads
new ShutdownMonitorThread().start();
}
Aggregations