/** * Enable all plugins of the given load order type. * * @param type The type of plugin to enable. */ private void enablePlugins(PluginLoadOrder type) { if (type == PluginLoadOrder.STARTUP) { helpMap.clear(); helpMap.initializeGeneralTopics(); } // load all the plugins Plugin[] plugins = pluginManager.getPlugins(); for (Plugin plugin : plugins) { if (!plugin.isEnabled() && plugin.getDescription().getLoad() == type) { List<Permission> perms = plugin.getDescription().getPermissions(); for (Permission perm : perms) { try { pluginManager.addPermission(perm); } catch (IllegalArgumentException ex) { getLogger() .log( Level.WARNING, "Plugin " + plugin.getDescription().getFullName() + " tried to register permission '" + perm.getName() + "' but it's already registered", ex); } } try { pluginManager.enablePlugin(plugin); } catch (Throwable ex) { logger.log(Level.SEVERE, "Error loading " + plugin.getDescription().getFullName(), ex); } } } if (type == PluginLoadOrder.POSTWORLD) { commandMap.setFallbackCommands(); commandMap.registerServerAliases(); DefaultPermissions.registerCorePermissions(); helpMap.initializeCommands(); // load permissions.yml ConfigurationSection permConfig = config.getConfigFile(ServerConfig.Key.PERMISSIONS_FILE); List<Permission> perms = Permission.loadPermissions( permConfig.getValues(false), "Permission node '%s' in permissions config is invalid", PermissionDefault.OP); for (Permission perm : perms) { try { pluginManager.addPermission(perm); } catch (IllegalArgumentException ex) { getLogger() .log( Level.WARNING, "Permission config tried to register '" + perm.getName() + "' but it's already registered", ex); } } } }
/** Starts this server. */ public void start() { // Determine console mode and start reading input consoleManager.startConsole(config.getBoolean(ServerConfig.Key.USE_JLINE)); consoleManager.startFile(config.getString(ServerConfig.Key.LOG_FILE)); if (getProxySupport()) { if (getOnlineMode()) { logger.warning("Proxy support is enabled, but online mode is enabled."); } else { logger.info("Proxy support is enabled."); } } else if (!getOnlineMode()) { logger.warning( "The server is running in offline mode! Only do this if you know what you're doing."); } // Load player lists opsList.load(); whitelist.load(); nameBans.load(); ipBans.load(); // DRAGONET-Start this.dragonetServer = new DragonetServer(this); this.dragonetServer.initialize(); // DRAGONET-End // Start loading plugins loadPlugins(); enablePlugins(PluginLoadOrder.STARTUP); // Create worlds String name = config.getString(ServerConfig.Key.LEVEL_NAME); String seedString = config.getString(ServerConfig.Key.LEVEL_SEED); boolean structs = getGenerateStructures(); WorldType type = WorldType.getByName(getWorldType()); if (type == null) { type = WorldType.NORMAL; } long seed = new Random().nextLong(); if (!seedString.isEmpty()) { try { long parsed = Long.parseLong(seedString); if (parsed != 0) { seed = parsed; } } catch (NumberFormatException ex) { seed = seedString.hashCode(); } } createWorld( WorldCreator.name(name) .environment(Environment.NORMAL) .seed(seed) .type(type) .generateStructures(structs)); if (getAllowNether()) { createWorld( WorldCreator.name(name + "_nether") .environment(Environment.NETHER) .seed(seed) .type(type) .generateStructures(structs)); } if (getAllowEnd()) { createWorld( WorldCreator.name(name + "_the_end") .environment(Environment.THE_END) .seed(seed) .type(type) .generateStructures(structs)); } // Finish loading plugins enablePlugins(PluginLoadOrder.POSTWORLD); commandMap.registerServerAliases(); scheduler.start(); }