/** Loads all plugins, calling onLoad, &c. */ private void loadPlugins() { // clear the map commandMap.removeAllOfType(PluginCommand.class); File folder = new File(config.getString("server.folders.plugins", "plugins")); folder.mkdirs(); // clear plugins and prepare to load pluginManager.clearPlugins(); pluginManager.registerInterface(JavaPluginLoader.class); Plugin[] plugins = pluginManager.loadPlugins(folder); // call onLoad methods for (Plugin plugin : plugins) { try { plugin.onLoad(); } catch (Exception ex) { logger.log( Level.SEVERE, "Error loading {0}: {1}", new Object[] {plugin.getDescription().getName(), ex.getMessage()}); ex.printStackTrace(); } } }
/** 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(); }