コード例 #1
0
  /** Loads all plugins, calling onLoad, &c. */
  private void loadPlugins() {
    // clear the map
    commandMap.clearCommands();
    commandMap.register("glowstone", new ColorCommand("colors"));
    commandMap.register("glowstone", new TellrawCommand());

    File folder = new File(config.getString(ServerConfig.Key.PLUGIN_FOLDER));
    if (!folder.isDirectory() && !folder.mkdirs()) {
      logger.log(Level.SEVERE, "Could not create plugins directory: " + folder);
    }

    // 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 " + plugin.getDescription().getFullName(), ex);
      }
    }
  }
コード例 #2
0
ファイル: GlowServer.java プロジェクト: hef/Glowstone
  /** 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();
      }
    }
  }
コード例 #3
0
ファイル: CraftServer.java プロジェクト: wmchris/BukkitForge
  /** @author CraftCraft */
  public void loadPlugins() {
    pluginManager.registerInterface(JavaPluginLoader.class);

    File pluginFolder = theServer.getFile("plugins");

    if (pluginFolder.exists()) {
      this.theLogger.info("Plugins are being loaded...");
      Plugin[] plugins = pluginManager.loadPlugins(pluginFolder);
      for (Plugin plugin : plugins) {
        try {
          String message = String.format("Loading %s", plugin.getDescription().getFullName());
          plugin.getLogger().info(message);
          plugin.onLoad();
        } catch (Throwable ex) {
          Logger.getLogger(CraftServer.class.getName())
              .log(
                  Level.SEVERE,
                  ex.getMessage()
                      + " initializing "
                      + plugin.getDescription().getFullName()
                      + " (Is it up to date?)",
                  ex);
        }
      }
    } else {
      theLogger.info("Plugin folder doesn't exist: " + pluginFolder.getAbsolutePath());
      pluginFolder.mkdir();
    }
  }
コード例 #4
0
ファイル: Citizens.java プロジェクト: Chuckleluck/Citizens2
 private void enableSubPlugins() {
   File root = new File(getDataFolder(), Setting.SUBPLUGIN_FOLDER.asString());
   if (!root.exists() || !root.isDirectory()) return;
   File[] files = root.listFiles();
   for (File file : files) {
     Plugin plugin;
     try {
       plugin = Bukkit.getPluginManager().loadPlugin(file);
     } catch (Exception e) {
       continue;
     }
     if (plugin == null) continue;
     // code beneath modified from CraftServer
     try {
       Messaging.logTr(Messages.LOADING_SUB_PLUGIN, plugin.getDescription().getFullName());
       plugin.onLoad();
     } catch (Throwable ex) {
       Messaging.severeTr(
           Messages.ERROR_INITALISING_SUB_PLUGIN,
           ex.getMessage(),
           plugin.getDescription().getFullName());
       ex.printStackTrace();
     }
   }
   ((CraftServer) Bukkit.getServer()).enablePlugins(PluginLoadOrder.POSTWORLD);
 }