Search in sources :

Example 1 with SourceInterface

use of cn.nukkit.network.SourceInterface in project Nukkit by Nukkit.

the class Server method forceShutdown.

public void forceShutdown() {
    if (this.hasStopped) {
        return;
    }
    try {
        if (!this.isRunning) {
        // todo sendUsage
        }
        // clean shutdown of console thread asap
        this.console.shutdown();
        this.hasStopped = true;
        this.shutdown();
        if (this.rcon != null) {
            this.rcon.close();
        }
        this.getLogger().debug("Disabling all plugins");
        this.pluginManager.disablePlugins();
        for (Player player : new ArrayList<>(this.players.values())) {
            player.close(player.getLeaveMessage(), (String) this.getConfig("settings.shutdown-message", "Server closed"));
        }
        this.getLogger().debug("Unloading all levels");
        for (Level level : this.levelArray) {
            this.unloadLevel(level, true);
        }
        this.getLogger().debug("Removing event handlers");
        HandlerList.unregisterAll();
        this.getLogger().debug("Stopping all tasks");
        this.scheduler.cancelAllTasks();
        this.scheduler.mainThreadHeartbeat(Integer.MAX_VALUE);
        this.getLogger().debug("Closing console");
        this.console.interrupt();
        this.getLogger().debug("Stopping network interfaces");
        for (SourceInterface interfaz : this.network.getInterfaces()) {
            interfaz.shutdown();
            this.network.unregisterInterface(interfaz);
        }
        this.getLogger().debug("Disabling timings");
        Timings.stopServer();
    // todo other things
    } catch (Exception e) {
        // todo remove this?
        this.logger.logException(e);
        this.logger.emergency("Exception happened while shutting down, exit the process");
        System.exit(1);
    }
}
Also used : SourceInterface(cn.nukkit.network.SourceInterface) Level(cn.nukkit.level.Level)

Aggregations

Level (cn.nukkit.level.Level)1 SourceInterface (cn.nukkit.network.SourceInterface)1