/** Binds the rcon server to the address specified in the configuration. */ private void bindRcon() { if (!config.getBoolean(ServerConfig.Key.RCON_ENABLED)) { return; } SocketAddress address = getBindAddress(ServerConfig.Key.RCON_PORT); rconServer = new RconServer(this, config.getString(ServerConfig.Key.RCON_PASSWORD)); logger.info("Binding rcon to address: " + address + "..."); ChannelFuture future = rconServer.bind(address); Channel channel = future.awaitUninterruptibly().channel(); if (!channel.isActive()) { logger.warning("Failed to bind rcon. Address already in use?"); } }
/** 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(); }