示例#1
0
  private static ExplosivesConfig loadConfig(
      FileConfiguration config, CustomLogger mainLogger, CustomLogger secondLogger) {
    boolean isDebugMode = ExplosivesConfig.isDebugMode(config, mainLogger);
    mainLogger.setDebugMode(isDebugMode);
    if (secondLogger != null) {
      secondLogger.setDebugMode(isDebugMode);
    }

    return ExplosivesConfig.getFromConfig(config, mainLogger);
  }
示例#2
0
  @Override
  public void onDisable() {
    HandlerList.unregisterAll(this);
    saveTask.cancel();

    unloadExplosives();
    saveData();

    consoleLogger.info("Plugin disabled");
  }
示例#3
0
 private void unloadExplosives() {
   Iterator<Recipe> iterator = getServer().recipeIterator();
   while (iterator.hasNext()) {
     Recipe recipe = iterator.next();
     EItem explosive = explosivesConfig.searchExplosiveByItemStack(recipe.getResult());
     if (explosive != null) {
       iterator.remove();
       consoleLogger.info("Removed " + explosive);
     }
   }
 }
示例#4
0
  private void loadExplosives() {
    List<EItem> explosives = explosivesConfig.getExplosives();
    int explosivesSize = explosives.size();
    //noinspection ForLoopReplaceableByForEach
    for (int i = 0; i < explosivesSize; i++) {
      EItem explosive = explosives.get(i);

      ShapedRecipe shapedRecipe = explosive.getShapedRecipe();
      getServer().addRecipe(shapedRecipe);
      consoleLogger.info("Added " + explosive);
    }
  }
示例#5
0
  @Override
  public void onEnable() {
    saveDefaultConfig();
    consoleLogger = new CustomLogger(getLogger());

    blockMetaStorage = new BlockMetaStorage(this, getDataFolder(), consoleLogger);
    repeaterTaskStorage = new RepeaterTaskStorage(this, getDataFolder(), consoleLogger);
    explosivesConfig = loadConfig(getConfig(), consoleLogger);
    repeaterTaskStorage.restore();
    loadExplosives();

    saveTask = new TaskPeriodicSave(this).runTaskTimer(this, SAVE_INTERVAL, SAVE_INTERVAL);

    getServer()
        .getPluginManager()
        .registerEvents(new ExplosivesBlocksListener(this, consoleLogger), this);
    getServer()
        .getPluginManager()
        .registerEvents(new ExplosivesActivateListener(this, consoleLogger), this);
    getServer().getPluginManager().registerEvents(new ExplosivesCraftListener(this), this);
    getCommand(COMMAND_NS).setExecutor(new CustomNukesCommandExecutor(this));

    consoleLogger.info("Plugin enabled");
  }