Exemple #1
0
  /** Stops this server. */
  public void shutdown() {
    // This is so we don't run this twice (/stop and actual shutdown)
    if (isShuttingDown) return;
    isShuttingDown = true;
    logger.info("The server is shutting down...");

    monitor.interrupt();

    // Stop scheduler and disable plugins
    scheduler.stop();
    pluginManager.clearPlugins();

    // Kick (and save) all players
    for (Player player : getOnlinePlayers()) {
      player.kickPlayer("Server shutting down.");
    }

    // Save worlds
    for (World world : getWorlds()) {
      unloadWorld(world, true);
    }
    storeQueue.end();

    // Gracefully stop Netty
    group.close();
    bootstrap.getFactory().releaseExternalResources();

    // And finally kill the console
    consoleManager.stop();
  }
  /** Stops this server. */
  @Override
  public void shutdown() {
    // Just in case this gets called twice
    if (isShuttingDown) {
      return;
    }
    isShuttingDown = true;
    logger.info("The server is shutting down...");

    // Disable plugins
    pluginManager.clearPlugins();

    // Kick all players (this saves their data too)
    for (Player player : getOnlinePlayers()) {
      player.kickPlayer(getShutdownMessage());
    }

    // Stop the network servers - starts the shutdown process
    // It may take a second or two for Netty to totally clean up
    networkServer.shutdown();
    if (queryServer != null) {
      queryServer.shutdown();
    }
    if (rconServer != null) {
      rconServer.shutdown();
    }

    // Save worlds
    for (World world : getWorlds()) {
      logger.info("Saving world: " + 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();
  }