Esempio n. 1
0
  /** Starts this server. */
  public void start() {
    // Config should have already loaded by this point, but to be safe...
    config.load();
    consoleManager.setupConsole();

    // Load player lists
    opsList.load();
    whitelist.load();
    banManager.load();

    // Start loading plugins
    loadPlugins();

    // Begin registering permissions
    DefaultPermissions.registerCorePermissions();

    // Register these first so they're usable while the worlds are loading
    GlowCommandMap.initGlowPermissions(this);
    commandMap.register(new MeCommand(this));
    commandMap.register(new ColorCommand(this));
    commandMap.register(new KickCommand(this));
    commandMap.register(new ListCommand(this));
    commandMap.register(new TimeCommand(this));
    commandMap.register(new WhitelistCommand(this));
    commandMap.register(new BanCommand(this));
    commandMap.register(new GameModeCommand(this));
    commandMap.register(new OpCommand(this));
    commandMap.register(new DeopCommand(this));
    commandMap.register(new StopCommand(this));
    commandMap.register(new SaveCommand(this));
    commandMap.register(new SayCommand(this));
    commandMap.removeAllOfType(ReloadCommand.class);
    commandMap.register(new ReloadCommand(this));
    commandMap.register(new HelpCommand(this, commandMap.getKnownCommands(false)));

    enablePlugins(PluginLoadOrder.STARTUP);

    // Create worlds
    String world = config.getString("server.world-name", "world");
    createWorld(WorldCreator.name(world).environment(Environment.NORMAL));
    if (getAllowNether()) {
      createWorld(WorldCreator.name(world + "_nether").environment(Environment.NETHER));
    }
    if (getAllowEnd()) {
      createWorld(WorldCreator.name(world + "_the_end").environment(Environment.THE_END));
    }

    // Finish loading plugins
    enablePlugins(PluginLoadOrder.POSTWORLD);
    commandMap.registerServerAliases();
    consoleManager.refreshCommands();
  }
Esempio n. 2
0
	/**
	 * @author CraftBukkit
	 */
	public void enablePlugins(PluginLoadOrder type) {
		if (type == PluginLoadOrder.STARTUP) {
			theHelpMap.clear();
			theHelpMap.initializeGeneralTopics();
		}

		Plugin[] plugins = pluginManager.getPlugins();

		for (Plugin plugin : plugins) {
			if ((!plugin.isEnabled()) && (plugin.getDescription().getLoad() == type)) {
				loadPlugin(plugin);
			}
		}

		if (type == PluginLoadOrder.POSTWORLD) {
			//this.theAliasMap.registerServerAliases();
			loadCustomPermissions();
			DefaultPermissions.registerCorePermissions();
			//theHelpMap.initializeCommands();
		}
	}
Esempio n. 3
0
  /** Reloads the server, refreshing settings and plugin information */
  public void reload() {
    try {
      // Reload relevant configuration
      config.load();
      opsList.load();
      whitelist.load();

      // Reset crafting
      craftingManager.resetRecipes();

      // Load plugins
      loadPlugins();
      DefaultPermissions.registerCorePermissions();
      GlowCommandMap.initGlowPermissions(this);
      commandMap.registerAllPermissions();
      enablePlugins(PluginLoadOrder.STARTUP);
      enablePlugins(PluginLoadOrder.POSTWORLD);
      commandMap.registerServerAliases();
      consoleManager.refreshCommands();
    } catch (Exception ex) {
      logger.log(Level.SEVERE, "Uncaught error while reloading: {0}", ex.getMessage());
      ex.printStackTrace();
    }
  }
Esempio n. 4
0
  /**
   * 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);
        }
      }
    }
  }