コード例 #1
0
  private void onEnablePost() {
    loaded = true;

    PluginManager pm = getServer().getPluginManager();

    scanPlugins(); // scan for other plugins and store them in case any use our API

    FlagFactory.getInstance().init();
    FlagFactory.getInstance().initPermissions();
    RecipeBooks.getInstance().init();
    RecipeBooks.getInstance().reload(null);

    Files.init();
    Players.init();
    Workbenches.init();

    reload(null, false, true); // load data

    pm.callEvent(
        new RecipeManagerEnabledEvent()); // Call the enabled event to notify other plugins that use
    // this plugin's API

    // Register commands
    getCommand("rm").setExecutor(new HelpCommand());
    getCommand("rmrecipes").setExecutor(new RecipeCommand());
    getCommand("rmfinditem").setExecutor(new FindItemCommand());
    getCommand("rmcheck").setExecutor(new CheckCommand());
    getCommand("rmreload").setExecutor(new ReloadCommand());
    getCommand("rmreloadbooks").setExecutor(new ReloadBooksCommand());
    getCommand("rmextract").setExecutor(new ExtractCommand());
    getCommand("rmgetbook").setExecutor(new GetBookCommand());
    getCommand("rmbooks").setExecutor(new BooksCommand());
    getCommand("rmupdate").setExecutor(new UpdateCommand());
    getCommand("rmcreaterecipe").setExecutor(new CreateRecipeCommand());
  }
コード例 #2
0
  /**
   * Reload RecipeManager's settings, messages, etc and re-parse recipes.
   *
   * @param sender To whom to send the messages to, null = console.
   * @param check Set to true to only check recipes, settings are unaffected.
   */
  public void reload(CommandSender sender, boolean check, boolean firstTime) {
    Settings.getInstance().reload(sender); // (re)load settings
    Messages.getInstance().reload(sender); // (re)load messages from messages.yml
    Files.reload(sender); // (re)generate info files if they do not exist

    Updater.init(this, 32835, null);

    if (metrics == null) {
      if (Settings.getInstance().getMetrics()) { // start/stop metrics accordingly
        try {
          metrics = new Metrics(this);
          metrics.start();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    } else {
      metrics.stop();
    }
    if (!check) {
      if (Settings.getInstance().getClearRecipes() || !firstTime) {
        Vanilla.removeAllButSpecialRecipes();
        Recipes.getInstance().clean();
      }

      if (!firstTime && !Settings.getInstance().getClearRecipes()) {
        Vanilla.restoreAllButSpecialRecipes();
        Recipes.getInstance().index.putAll(Vanilla.initialRecipes);
      }
    }

    RecipeProcessor.reload(sender, check); // (re)parse recipe files
    Events.reload(); // (re)register events
  }