Exemple #1
0
  public void onDisable() {
    this.getLogger().info("Disabling Minecraftno plugin...");

    // Enable whitelist to stop players joining while we're shutting down.
    if (this.getConfig().getBoolean("whitelist.on_disable.toggle", false)) {
      this.getServer()
          .setWhitelist(this.getConfig().getBoolean("whitelist.on_disable.toggle", true));

      // Kick everyone who's already online before we start disabling functionality.
      // They're not supposed to be here anyway.
      for (Player player : this.getServer().getOnlinePlayers()) {
        player.kickPlayer(
            this.getConfig().getString("whitelist.message", "The server is shutting down..."));
      }
    }

    if (configuration.irc && bot.isConnected()) {
      this.getLogger().info(" - Disabling IRC bot...");
      bot.disconnect();
      bot.dispose();
    }

    this.getLogger().info(" - Handlers cleanup...");
    this.groupHandler.cleanup();
    this.userHandler.cleanup();

    try {
      configuration.cleanup();
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (this.blockHandler != null) {
      if (this.blockHandler.getQueueSize() > 0) {
        this.getLogger().info(" - Waiting for block handler to finish...");

        try {
          Thread.sleep(3000);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
        this.blockHandler.run();
      }
    }

    if (sqlc != null) {
      this.getLogger().info(" - Closing SQL connection...");
      sqlc.close();
    }

    this.getLogger().info(" - Cancelling scheduled tasks...");
    getServer().getScheduler().cancelAllTasks();

    this.getLogger().info("Finished disabling Minecraftno plugin.");
  }
 // This may be aborted if there are stagnant requests sitting in queue.
 // This needs fixed to discard outstanding save requests.
 public synchronized void forceSave() {
   try {
     Future<?> future = delayedSave(configFile);
     if (future != null) {
       future.get();
     }
   } catch (InterruptedException ex) {
     LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
   } catch (ExecutionException ex) {
     LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
   }
 }