public static void set(String categoryName, String propertyName, String newValue) {
   config.load();
   if (config.getCategoryNames().contains(categoryName)) {
     if (config.getCategory(categoryName).containsKey(propertyName)) {
       config.getCategory(categoryName).get(propertyName).set(newValue);
     }
   }
   config.save();
 }
 @Override
 public void saveConfig(Configuration config) {
   if (config.getCategory("addshapedore") != null) config.getCategory("addshapedore").clear();
   if (config.getCategory("addshapelessore") != null)
     config.getCategory("addshapelessore").clear();
   for (int zahl = 0; zahl < addedRecipes.size(); zahl++) {
     IRecipe recipeO = (IRecipe) addedRecipes.get(zahl);
     if (recipeO != null)
       config.get(
           "add" + WorkbenchHelper.getRecipeCategoryString(recipeO),
           WorkbenchHelper.RecipeToString(recipeO),
           true);
   }
 }
Example #3
0
  public static void init(File file) {
    config = new Configuration(file);

    config.load();

    config.getCategory(CATEGORY_MAIN);

    DISABLE_HEALTH_REGEN =
        config
            .get(
                CATEGORY_MAIN,
                DISABLE_HEALTH_REGEN_NAME,
                DISABLE_HEALTH_REGEN_DEFAULT,
                DISABLE_HEALTH_REGEN_COMMENT)
            .getBoolean(true);
    MIN_HEALTH_FROM_STARVATION =
        (float)
            config
                .get(
                    CATEGORY_MAIN,
                    MIN_HEALTH_FROM_STARVATION_NAME,
                    MIN_HEALTH_FROM_STARVATION_DEFAULT,
                    MIN_HEALTH_FROM_STARVATION_COMMENT)
                .getDouble(MIN_HEALTH_FROM_STARVATION_DEFAULT);

    config.save();
  }
Example #4
0
 /**
  * Disables metrics for the server by setting "opt-out" to true in the config file and canceling
  * the metrics task.
  *
  * @throws java.io.IOException
  */
 public void disable() throws IOException {
   // Check if the server owner has already set opt-out, if not, set it.
   if (!isOptOut()) {
     configuration.getCategory(Configuration.CATEGORY_GENERAL).get("opt-out").set("true");
     configuration.save();
   }
   FMLCommonHandler.instance().bus().unregister(this);
 }
Example #5
0
 /**
  * Enables metrics for the server by setting "opt-out" to false in the config file and starting
  * the metrics task.
  *
  * @throws java.io.IOException
  */
 public void enable() throws IOException {
   // Check if the server owner has already set opt-out, if not, set it.
   if (isOptOut()) {
     configuration.getCategory(Configuration.CATEGORY_GENERAL).get("opt-out").set("false");
     configuration.save();
   }
   // Enable Task, if it is not running
   FMLCommonHandler.instance().bus().register(this);
 }
  @Override
  public void loadConfig(Configuration config) {
    addedRecipes.clear();

    // items|result|x|y
    Map<String, Property> shaped = config.getCategory("addshapedore").getValues();
    for (int zahl = 0; zahl < shaped.size(); zahl++) {
      Property RecipeData = (Property) shaped.values().toArray()[zahl];
      String Data = RecipeData.getName();
      IRecipe recipe = WorkbenchHelper.StringToRecipe(true, Data);
      if (recipe != null) addedRecipes.add(recipe);
    }

    Map<String, Property> shapless = config.getCategory("addshapelessore").getValues();
    for (int zahl = 0; zahl < shapless.size(); zahl++) {
      Property RecipeData = (Property) shapless.values().toArray()[zahl];
      String Data = RecipeData.getName();
      IRecipe recipe = WorkbenchHelper.StringToRecipe(false, Data);
      if (recipe != null) addedRecipes.add(recipe);
    }
    CraftingManager.getInstance().getRecipeList().addAll(addedRecipes);
  }
 private void saveGroup(String parentName, ConfigGroupData groupData) {
   String catName = (parentName == null ? "" : (parentName + ".")) + groupData.name();
   ConfigCategory forgeCat = forgeConfig.getCategory(catName);
   forgeCat.setComment(groupData.comment());
   // Save Properties
   if (groupData.getProperties() != null) {
     for (ConfigPropertyData propData : groupData.getProperties()) {
       saveProperty(forgeCat, propData);
     }
   }
   // Save Children
   if (groupData.getChildGroups() != null) {
     for (ConfigGroupData childGroup : groupData.getChildGroups()) {
       saveGroup(catName, childGroup);
     }
   }
 }
 @Override
 public void saveConfig(Configuration c) {
   c.getCategory(CATEGORY_MFFS).get("internalEnergyPerInput").set(_internalEnergyPerInput);
   c.getCategory(CATEGORY_MFFS).get("internalEnergyPerOutput").set(_internalEnergyPerOutput);
 }