예제 #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
  @Override
  public void onDisable() {
    try {
      Bukkit.getScheduler().cancelTasks(this);

      if (plugin == null) {
        return;
      }

      Vanilla.removeCustomRecipes();

      Furnaces.save();
      Furnaces.clean();

      BrewingStands.save();
      BrewingStands.clean();

      Workbenches.clean();
      Players.clean();
      Vanilla.clean();

      recipes.clean();
      recipes = null;

      recipeBooks.clean();
      recipeBooks = null;

      events.clean();
      events = null;

      Settings.clean();

      Econ.getInstance().clean();
      Perms.getInstance().clean();

      if (metrics != null) {
        metrics.stop();
        metrics = null;
      }

      plugin = null;
    } catch (Throwable e) {
      MessageSender.getInstance().error(null, e, null);
    }
  }