Jump to content

[1.8]Making configurations for Biome and Dimension IDs


NovaViper

Recommended Posts

Hey, is it possible to make configurations for biome and dimension IDs? If so, how do I do it? Some mods like Biomes O Plenty and Twilight Forest achieved this. I already have set up a configuration file that can accessed in game through the title menu on my Github: https://github.com/NovaViper/ZeroQuest/tree/master/src/main/java/common/zeroquest

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

  • Replies 82
  • Created
  • Last Reply

Top Posters In This Topic

The problem is, in my WorldGenerator, it says that the ideas have to be constant, but I have to have the IDs not constant in order to have them configurable.

Show the code and error's place... Also, you can create non static final fileds and initialize them in constructor taking value from config (or config handler)...

Link to comment
Share on other sites

It's all on my Github. ECLIPSE is telling me that the case has to be constant here

 

			case IDs.Nillax:
			generateNillaxDimension(world, random, chunkX * 16, chunkZ * 16);
		case IDs.Darkax:
			if (Constants.DEF_DARKLOAD == true) {
				generateDarkaxDimension(world, random, chunkX * 16, chunkZ * 16);
			}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

hey, I'm having a bit of trouble organizing my configurations. I'm trying to get the biome configurations to aline as I have them ordered in the code.

 

Here is the code

 

	public static void loadConfig() {
	List<String> propOrder = new ArrayList<String>();
	Property propLoad;
	Property propFunction;
	Property propMisc;
	Property propDim;
	Property propBiome;

	config.addCustomCategoryComment(CATEGORY_FUNCTION, "Here you can manage all mod and entity functions");
	config.addCustomCategoryComment(CATEGORY_LOAD, "Here you can manage what the mod loads into the game");
	config.addCustomCategoryComment(CATEGORY_MISC, "Here you can manage the miscellaneous functions of the mod");
	config.addCustomCategoryComment(CATEGORY_DIMENSION, "Here you can manage the mod's dimension factors");
	config.addCustomCategoryComment(CATEGORY_BIOME, "Here you can manage the mod's biome factors");

	//@formatter:off
	/*=================================Load Configurations==========================================*/
	//@formatter:on
	propLoad = config.get(CATEGORY_LOAD, "DarkElements", false);
	propLoad.comment = "Toggles the Dark Elemental Load";
	propLoad.setLanguageKey("gui.config.property.DarkElements").setRequiresMcRestart(true);
	Constants.DEF_DARKLOAD = propLoad.getBoolean(Constants.DEF_DARKLOAD);

	propLoad = config.get(CATEGORY_LOAD, "StartingItems", true);
	propLoad.comment = "Toggles spawning in a world with a Command Seal";
	propLoad.setLanguageKey("gui.config.property.StartingItems");
	Constants.DEF_STARTING_ITEMS = propLoad.getBoolean(Constants.DEF_STARTING_ITEMS);

	propLoad = config.get(CATEGORY_LOAD, "ModCheck", true);
	propLoad.comment = "Toggles the mod's version checker";
	propLoad.setLanguageKey("gui.config.property.ModCheck");
	Constants.DEF_MODCHECKER = propLoad.getBoolean(Constants.DEF_MODCHECKER);

	propOrder.add(propLoad.getName());
	//@formatter:off
	/*=================================Function Configurations==========================================*/
	//@formatter:on
	propFunction = config.get(CATEGORY_FUNCTION, "Healing", false);
	propFunction.comment = "Toggles the healing ability of ALL ZQ tameable creatures";
	propFunction.setLanguageKey("gui.config.property.Healing");
	Constants.DEF_HEALING = propFunction.getBoolean(Constants.DEF_HEALING);

	propFunction = config.get(CATEGORY_FUNCTION, "SnowStep", true);
	propFunction.comment = "Toggles the snow/ice footprints of Ice Zertums";
	propFunction.setLanguageKey("gui.config.property.SnowStep");
	Constants.DEF_SNOWSTEP = propFunction.getBoolean(Constants.DEF_SNOWSTEP);

	propFunction = config.get(CATEGORY_FUNCTION, "GrassStep", true);
	propFunction.comment = "Toggles the grass footprints of Foris Zertums";
	propFunction.setLanguageKey("gui.config.property.GrassStep");
	Constants.DEF_GRASSSTEP = propFunction.getBoolean(Constants.DEF_GRASSSTEP);

	propOrder.add(propFunction.getName());
	//@formatter:off
	/*=================================Miscellaneous Configurations==========================================*/
	//@formatter:on
	propMisc = config.get(CATEGORY_MISC, "Howl", true);
	propMisc.comment = "Toggles the howling function on Zertums";
	propMisc.setLanguageKey("gui.config.property.Howl");
	Constants.DEF_HOWL = propMisc.getBoolean(Constants.DEF_HOWL);

	propMisc = config.get(CATEGORY_MISC, "HungerDecay", true);
	propMisc.comment = "Toggles the hunger decay on Zertums";
	propMisc.setLanguageKey("gui.config.property.HungerDecay");
	Constants.DEF_IS_HUNGER_ON = propMisc.getBoolean(Constants.DEF_IS_HUNGER_ON);

	propOrder.add(propMisc.getName());
	//@formatter:off
	/*=================================DimensionsConfigurations==========================================*/
	//@formatter:on

	propDim = config.get(CATEGORY_DIMENSION, "NillaxID", IDs.Nillax);
	propDim.comment = "ID of the Nillax Dimension";
	propDim.setLanguageKey("gui.config.property.NillaxID").setRequiresMcRestart(true);
	IDs.Nillax = propDim.getInt(IDs.Nillax);

	propDim = config.get(CATEGORY_DIMENSION, "DarkaxID", IDs.Darkax);
	propDim.comment = "ID of the Darkax Dimension";
	propDim.setLanguageKey("gui.config.property.DarkaxID").setRequiresMcRestart(true);
	IDs.Darkax = propDim.getInt(IDs.Darkax);

	propOrder.add(propDim.getName());
	//@formatter:off
	/*=================================BiomesConfigurations==========================================*/
	//@formatter:on

	propBiome = config.get(CATEGORY_BIOME, "BioZoneID", IDs.bioZone);
	propBiome.comment = "ID of the Bio Zone Biome";
	propBiome.setLanguageKey("gui.config.property.BioZoneID").setRequiresMcRestart(true);
	IDs.bioZone = propBiome.getInt(IDs.bioZone);

	propBiome = config.get(CATEGORY_BIOME, "RedSeedID", IDs.redSeed);
	propBiome.comment = "ID of the Red Seed Biome";
	propBiome.setLanguageKey("gui.config.property.RedSeedID").setRequiresMcRestart(true);
	IDs.redSeed = propBiome.getInt(IDs.redSeed);

	propBiome = config.get(CATEGORY_BIOME, "BlueTaigaID", IDs.blueTaiga);
	propBiome.comment = "ID of the Blue Taiga Biome";
	propBiome.setLanguageKey("gui.config.property.BlueTaigaID").setRequiresMcRestart(true);
	IDs.blueTaiga = propBiome.getInt(IDs.blueTaiga);

	propBiome = config.get(CATEGORY_BIOME, "BlueTaigaHillsID", IDs.blueTaigaHills);
	propBiome.comment = "ID of the Blue Taiga Hills Biome";
	propBiome.setLanguageKey("gui.config.property.BlueTaigaHillsID").setRequiresMcRestart(true);
	IDs.blueTaigaHills = propBiome.getInt(IDs.blueTaigaHills);

	propBiome = config.get(CATEGORY_BIOME, "BlueColdTaigaID", IDs.blueColdTaiga);
	propBiome.comment = "ID of the Blue Cold Taiga Biome";
	propBiome.setLanguageKey("gui.config.property.BlueColdTaigaID").setRequiresMcRestart(true);
	IDs.blueColdTaiga = propBiome.getInt(IDs.blueColdTaiga);

	propBiome = config.get(CATEGORY_BIOME, "BlueColdTaigaHillsID", IDs.blueColdTaigaHills);
	propBiome.comment = "ID of the Blue Cold Taiga Hills Biome";
	propBiome.setLanguageKey("gui.config.property.BlueColdTaigaHillsID").setRequiresMcRestart(true);
	IDs.blueColdTaigaHills = propBiome.getInt(IDs.blueColdTaigaHills);

	propBiome = config.get(CATEGORY_BIOME, "PinkZoneID", IDs.pinkZone);
	propBiome.comment = "ID of the Pink Zone Biome";
	propBiome.setLanguageKey("gui.config.property.PinkZoneID").setRequiresMcRestart(true);
	IDs.pinkZone = propBiome.getInt(IDs.pinkZone);

	propBiome = config.get(CATEGORY_BIOME, "DestroZoneID", IDs.destroZone);
	propBiome.comment = "ID of the Destro Zone Biome";
	propBiome.setLanguageKey("gui.config.property.DestroZoneID").setRequiresMcRestart(true);
	IDs.destroZone = propBiome.getInt(IDs.destroZone);

	propBiome = config.get(CATEGORY_BIOME, "DestroZoneHillsID", IDs.destroZoneHills);
	propBiome.comment = "ID of the Destro Zone Hills Biome";
	propBiome.setLanguageKey("gui.config.property.DestroZoneHillsID").setRequiresMcRestart(true);
	IDs.destroZoneHills = propBiome.getInt(IDs.destroZoneHills);


	propOrder.add(propBiome.getDefault());

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

Oh and I modifed the code since I found an easier way to make the configurations

 

package common.zeroquest.core.handlers;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;

import org.apache.logging.log4j.Logger;

import common.zeroquest.ZeroQuest;
import common.zeroquest.lib.Constants;
import common.zeroquest.lib.IDs;

public class ConfigHandler {

// Add more Categories for GuiFactory\\ TODO
public static Configuration config;
public static final String CATEGORY_LOAD = "load";
public static final String CATEGORY_FUNCTION = "function";
public static final String CATEGORY_MISC = "miscellaneous";
public static final String CATEGORY_DIMENSION = "dimensions";
public static final String CATEGORY_BIOME = "biomes";

public static void init(File file) {
	config = new Configuration(file);

	loadConfig();
}

public static void loadConfig() {

	config.addCustomCategoryComment(CATEGORY_FUNCTION, "Here you can manage all mod and entity functions");
	config.addCustomCategoryComment(CATEGORY_LOAD, "Here you can manage what the mod loads into the game");
	config.addCustomCategoryComment(CATEGORY_MISC, "Here you can manage the miscellaneous functions of the mod");
	config.addCustomCategoryComment(CATEGORY_DIMENSION, "Here you can manage the mod's dimension factors");
	config.addCustomCategoryComment(CATEGORY_BIOME, "Here you can manage the mod's biome factors");

	//@formatter:off
	/*=================================Load Configurations==========================================*/
	//@formatter:on
	Constants.DEF_DARKLOAD = config.get(CATEGORY_LOAD, "DarkElements", Constants.DEF_DARKLOAD).setLanguageKey(Constants.guiKey + "DarkElements").setRequiresMcRestart(true).getBoolean(Constants.DEF_DARKLOAD);
	Constants.DEF_STARTING_ITEMS = config.get(CATEGORY_LOAD, "StartingItems", Constants.DEF_STARTING_ITEMS).setLanguageKey(Constants.guiKey + "StartingItems").getBoolean(Constants.DEF_STARTING_ITEMS);
	Constants.DEF_MODCHECKER = config.get(CATEGORY_LOAD, "ModCheck", Constants.DEF_MODCHECKER).setLanguageKey(Constants.guiKey + "ModCheck").getBoolean(Constants.DEF_MODCHECKER);

	//@formatter:off
	/*=================================Function Configurations==========================================*/
	//@formatter:on
	Constants.DEF_HEALING = config.get(CATEGORY_FUNCTION, "Healing", Constants.DEF_HEALING).setLanguageKey(Constants.guiKey + "Healing").getBoolean(Constants.DEF_HEALING);
	Constants.DEF_SNOWSTEP = config.get(CATEGORY_FUNCTION, "SnowStep", Constants.DEF_SNOWSTEP).setLanguageKey(Constants.guiKey + "SnowStep").getBoolean(Constants.DEF_SNOWSTEP);
	Constants.DEF_GRASSSTEP = config.get(CATEGORY_FUNCTION, "GrassStep", Constants.DEF_GRASSSTEP).setLanguageKey(Constants.guiKey + "GrassStep").getBoolean(Constants.DEF_GRASSSTEP);

	//@formatter:off
	/*=================================Miscellaneous Configurations==========================================*/
	//@formatter:on

	Constants.DEF_HOWL = config.get(CATEGORY_MISC, "Howl", Constants.DEF_HOWL).setLanguageKey(Constants.guiKey + "Howl").getBoolean(Constants.DEF_HOWL);
	Constants.DEF_IS_HUNGER_ON = config.get(CATEGORY_MISC, "HungerDecay", Constants.DEF_IS_HUNGER_ON).setLanguageKey(Constants.guiKey + "HungerDecay").getBoolean(Constants.DEF_IS_HUNGER_ON);

	//@formatter:off
	/*=================================DimensionsConfigurations==========================================*/
	//@formatter:on

	IDs.Nillax = config.get(CATEGORY_DIMENSION, "NillaxID", IDs.Nillax).setLanguageKey(Constants.guiKey + "NillaxID").setRequiresMcRestart(true).getInt(IDs.Nillax);
	IDs.Darkax = config.get(CATEGORY_DIMENSION, "DarkaxID", IDs.Darkax).setLanguageKey(Constants.guiKey + "DarkaxID").setRequiresMcRestart(true).getInt(IDs.Darkax);

	//@formatter:off
	/*=================================BiomesConfigurations==========================================*/
	//@formatter:on
	IDs.bioZone = config.get(CATEGORY_BIOME, "BioZoneID", IDs.bioZone).setLanguageKey(Constants.guiKey + "BioZoneID").setRequiresMcRestart(true).getInt(IDs.bioZone);
	IDs.redSeed = config.get(CATEGORY_BIOME, "RedSeedID", IDs.redSeed).setLanguageKey(Constants.guiKey + "RedSeedID").setRequiresMcRestart(true).getInt(IDs.redSeed);
	IDs.blueTaiga = config.get(CATEGORY_BIOME, "BlueTaigaID", IDs.blueTaiga).setLanguageKey(Constants.guiKey + "BlueTaigaID").setRequiresMcRestart(true).getInt(IDs.blueTaiga);
	IDs.blueTaigaHills = config.get(CATEGORY_BIOME, "BlueTaigaHillsID", IDs.blueTaigaHills).setLanguageKey(Constants.guiKey + "BlueTaigaHillsID").setRequiresMcRestart(true).getInt(IDs.blueTaigaHills);
	IDs.blueColdTaiga = config.get(CATEGORY_BIOME, "BlueColdTaigaID", IDs.blueColdTaiga).setLanguageKey(Constants.guiKey + "BlueColdTaigaID").setRequiresMcRestart(true).getInt(IDs.blueColdTaiga);
	IDs.blueColdTaigaHills = config.get(CATEGORY_BIOME, "BlueColdTaigaHillsID", IDs.blueColdTaigaHills).setLanguageKey(Constants.guiKey + "BlueColdTaigaHillsID").setRequiresMcRestart(true).getInt(IDs.blueColdTaigaHills);
	IDs.blueMegaTaiga = config.get(CATEGORY_BIOME, "BlueMegaTaigaID", IDs.blueMegaTaiga).setLanguageKey(Constants.guiKey + "BlueMegaTaigaID").setRequiresMcRestart(true).getInt(IDs.blueMegaTaiga);
	IDs.blueMegaTaigaHills = config.get(CATEGORY_BIOME, "BlueMegaTaigaHillsID", IDs.blueMegaTaigaHills).setLanguageKey(Constants.guiKey + "BlueMegaTaigaHillsID").setRequiresMcRestart(true).getInt(IDs.blueMegaTaigaHills);
	IDs.pinkZone = config.get(CATEGORY_BIOME, "PinkZoneID", IDs.pinkZone).setLanguageKey(Constants.guiKey + "PinkZoneID").setRequiresMcRestart(true).getInt(IDs.pinkZone);
	IDs.destroZone = config.get(CATEGORY_BIOME, "DestroZoneID", IDs.destroZone).setLanguageKey(Constants.guiKey + "DestroZoneID").setRequiresMcRestart(true).getInt(IDs.destroZone);
	IDs.destroZoneHills = config.get(CATEGORY_BIOME, "DestroZoneHillsID", IDs.destroZoneHills).setLanguageKey(Constants.guiKey + "DestroZoneHillsID").setRequiresMcRestart(true).getInt(IDs.destroZoneHills);
	IDs.walRockland = config.get(CATEGORY_BIOME, "WalRocklandID", IDs.walRockland).setLanguageKey(Constants.guiKey + "WalRocklandID").setRequiresMcRestart(true).getInt(IDs.walRockland);
	IDs.darkWasteland = config.get(CATEGORY_BIOME, "DarkaxBiomeID", IDs.darkWasteland).setLanguageKey(Constants.guiKey + "DarkaxBiomeID").setRequiresMcRestart(true).getInt(IDs.darkWasteland);
	IDs.nileSavanna = config.get(CATEGORY_BIOME, "NileSavannaID", IDs.nileSavanna).setLanguageKey(Constants.guiKey + "NileSavannaID").setRequiresMcRestart(true).getInt(IDs.nileSavanna);
	IDs.nileSavannaPlateau = config.get(CATEGORY_BIOME, "NileSavannaPlateauID", IDs.nileSavannaPlateau).setLanguageKey(Constants.guiKey + "NileSavannaPlateauID").setRequiresMcRestart(true).getInt(IDs.nileSavannaPlateau);
	IDs.nileJungle = config.get(CATEGORY_BIOME, "NileJungleID", IDs.nileJungle).setLanguageKey(Constants.guiKey + "NileJungleID").setRequiresMcRestart(true).getInt(IDs.nileJungle);
	IDs.nileJungleHills = config.get(CATEGORY_BIOME, "NileJungleHillsID", IDs.nileJungleHills).setLanguageKey(Constants.guiKey + "NileJungleHillsID").setRequiresMcRestart(true).getInt(IDs.nileJungleHills);
	IDs.nileJungleEdge = config.get(CATEGORY_BIOME, "NileJungleEdgeID", IDs.nileJungleEdge).setLanguageKey(Constants.guiKey + "NileJungleEdgeID").setRequiresMcRestart(true).getInt(IDs.nileJungleEdge);
	IDs.nileSwampland = config.get(CATEGORY_BIOME, "NileSwamplandID", IDs.nileSwampland).setLanguageKey(Constants.guiKey + "NileSwamplandID").setRequiresMcRestart(true).getInt(IDs.nileSwampland);
	IDs.nileMesa = config.get(CATEGORY_BIOME, "NileMesaID", IDs.nileMesa).setLanguageKey(Constants.guiKey + "NileMesaID").setRequiresMcRestart(true).getInt(IDs.nileMesa);
	IDs.nileMesaPlateau_F = config.get(CATEGORY_BIOME, "NileMesaPlateauFID", IDs.nileMesaPlateau_F).setLanguageKey(Constants.guiKey + "NileMesaPlateauFID").setRequiresMcRestart(true).getInt(IDs.nileMesaPlateau_F);
	IDs.nileMesaPlateau = config.get(CATEGORY_BIOME, "NileMesaPlateauID", IDs.nileMesaPlateau).setLanguageKey(Constants.guiKey + "NileMesaPlateauID").setRequiresMcRestart(true).getInt(IDs.nileMesaPlateau);
	IDs.nileMountains = config.get(CATEGORY_BIOME, "NileMountainsID", IDs.nileMountains).setLanguageKey(Constants.guiKey + "NileMountainsID").setRequiresMcRestart(true).getInt(IDs.nileMountains);
	IDs.nileMountainsEdge = config.get(CATEGORY_BIOME, "NileMountainsEdgeID", IDs.nileMountainsEdge).setLanguageKey(Constants.guiKey + "NileMountainsEdgeID").setRequiresMcRestart(true).getInt(IDs.nileMountainsEdge);
	IDs.nileMountainsPlus = config.get(CATEGORY_BIOME, "NileMountainsPlusID", IDs.nileMountainsPlus).setLanguageKey(Constants.guiKey + "NileMountainsPlusID").setRequiresMcRestart(true).getInt(IDs.nileMountainsPlus);

	if (config.hasChanged()) {
		config.save();
	}
}
}

 

But the game seems to be organizing the configurations alphabetical order still

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

Well.. I like my things to organized (depending on what it is), especially when it comes to coding, I aligned the biome by when I add them and their ID numbers. What Minecraft is doing is this

 

width=800 height=426http://i1319.photobucket.com/albums/t661/Nova_Leary/Reason_zpsifv9tv1n.png[/img]

 

This is completely opposite to what I have in my code so it is confusing for me

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

I know its not the place to promote personal work, but if you want more control over your configFile, I would recommend using my ConfigApi. Its capable to hold on to an order, and its more configurable. Though it can't be accesed ingame yet. Curently Im working on a API to make that possible as wel.

 

EDIT:

An less ellegant way to order the strings is by putting nubers in front of them.

( # - name)

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Link to comment
Share on other sites

I'll put numbers before them then, oh question, is it possible to use the In-Game Mod Options yet? I found a tutorial by jabelar like this http://jabelarminecraft.blogspot.com/p/minecraft-modding-configuration-guis.html

 

He mentioned that there is a class called GuiIngameModOptions that accesses that gui

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

It is possible, but with the forge ConfigSystem only! Since I made my own system it won't be compatible with this System. Thats why Im working on a custom easy-to-use in-ingameConfigSystem(usable while a World is running). Though in your case, I wouldn't recommend changing ID's while the game is running.

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Link to comment
Share on other sites

Think of it this way, is it your intention that every player may change the boolean/value? With Biome ID's its usualy only modpack creators who want to mess around with it. And they dont search for an ingame gui either, but use the .cfg files instead.

 

So if you have some booleans, is it usefull for an average player to have easy acces to it? If so, go ahead, otherwise you wouldn't recommend making it accesible ingame. Beside, you have to make sure it can't mess up the game if you would change it ingame.(which in the case of the ID's it could)

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Link to comment
Share on other sites

Ah.. I see your point and most likely with these, it's not useful. I have the parameters for the Biome IDs and Dimension IDs set to say that Minecraft must be restarted in order for the changes to take effect

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

Ok, i was digging a lot and if found interesting thing:

You can do what you want by:

 

Creating new class that extends Configuration

Creating another new class extending ConfigCategory

In 2nd class override getOrderedValues(), this is method responsible for sorting. Sort here your values in any way

Than in first class, override getCategory, and where it calls new ConfigCategory, call new YourConfigCategory instead

And the last thing: in your config handler, instead of calling new Configuration, call new YourConfiguration

 

That should work :) ...

 

 

Link to comment
Share on other sites

Now it's all blank. Here is my code.

 

ModConfiguration

package common.zeroquest.core.configuration;

import java.io.File;
import java.util.Map;
import java.util.TreeMap;

import net.minecraftforge.common.config.Configuration;

public class ModConfiguration extends Configuration {

private Map<String, ModConfigCategory> categories = new TreeMap<String, ModConfigCategory>();
private boolean changed = false;

public ModConfiguration() {}

/**
 * Create a configuration file for the file given in parameter.
 */
public ModConfiguration(File file) {
	super(file);
}

@Override
public ModConfigCategory getCategory(String category) {
	ModConfigCategory ret = categories.get(category);

	if (ret == null) {
		if (category.contains(CATEGORY_SPLITTER)) {
			String[] hierarchy = category.split("\\" + CATEGORY_SPLITTER);
			ModConfigCategory parent = categories.get(hierarchy[0]);

			if (parent == null) {
				parent = new ModConfigCategory(hierarchy[0]);
				categories.put(parent.getQualifiedName(), parent);
				changed = true;
			}

			for (int i = 1; i < hierarchy.length; i++) {
				String name = ModConfigCategory.getQualifiedName(hierarchy[i], parent);
				ModConfigCategory child = categories.get(name);

				if (child == null) {
					child = new ModConfigCategory(hierarchy[i], parent);
					categories.put(name, child);
					changed = true;
				}

				ret = child;
				parent = child;
			}
		}
		else {
			ret = new ModConfigCategory(category);
			categories.put(category, ret);
			changed = true;
		}
	}

	return ret;
}

}

 

ModConfigCategory

package common.zeroquest.core.configuration;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import com.google.common.collect.ImmutableList;

import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.Property;

public class ModConfigCategory extends ConfigCategory {

private Map<String, Property> properties = new TreeMap<String, Property>();

public ModConfigCategory(String name) {
	super(name);
}

public ModConfigCategory(String name, ModConfigCategory parent) {
	super(name, parent);
}

@Override
public List<Property> getOrderedValues() {

	return ImmutableList.copyOf(properties.values());
}

}

 

ConfigHandler

package common.zeroquest.core.handlers;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import net.minecraftforge.common.config.Property;

import org.apache.logging.log4j.Logger;

import common.zeroquest.ZeroQuest;
import common.zeroquest.core.configuration.ModConfiguration;
import common.zeroquest.lib.Constants;
import common.zeroquest.lib.IDs;

public class ConfigHandler {

// Add more Categories for GuiFactory\\
public static ModConfiguration config;
public static final String CATEGORY_LOAD = "load";
public static final String CATEGORY_FUNCTION = "function";
public static final String CATEGORY_MISC = "miscellaneous";
public static final String CATEGORY_DIMENSION = "dimensions";
public static final String CATEGORY_BIOME = "biomes";

public static void init(File file) {
	config = new ModConfiguration(file);

	loadConfig();
}

public static void loadConfig() {

	config.addCustomCategoryComment(CATEGORY_FUNCTION, "Here you can manage all mod and entity functions");
	config.addCustomCategoryComment(CATEGORY_LOAD, "Here you can manage what the mod loads into the game");
	config.addCustomCategoryComment(CATEGORY_MISC, "Here you can manage the miscellaneous functions of the mod");
	config.addCustomCategoryComment(CATEGORY_DIMENSION, "Here you can manage the mod's dimension factors");
	config.addCustomCategoryComment(CATEGORY_BIOME, "Here you can manage the mod's biome factors");

	//@formatter:off
	/*=================================Load Configurations==========================================*/
	//@formatter:on
	Constants.DEF_DARKLOAD = config.get(CATEGORY_LOAD, "DarkElements", Constants.DEF_DARKLOAD).setLanguageKey(Constants.guiKey + "DarkElements").setRequiresMcRestart(true).getBoolean(Constants.DEF_DARKLOAD);
	Constants.DEF_STARTING_ITEMS = config.get(CATEGORY_LOAD, "StartingItems", Constants.DEF_STARTING_ITEMS).setLanguageKey(Constants.guiKey + "StartingItems").getBoolean(Constants.DEF_STARTING_ITEMS);
	Constants.DEF_MODCHECKER = config.get(CATEGORY_LOAD, "ModCheck", Constants.DEF_MODCHECKER).setLanguageKey(Constants.guiKey + "ModCheck").getBoolean(Constants.DEF_MODCHECKER);

	//@formatter:off
	/*=================================Function Configurations==========================================*/
	//@formatter:on
	Constants.DEF_HEALING = config.get(CATEGORY_FUNCTION, "Healing", Constants.DEF_HEALING).setLanguageKey(Constants.guiKey + "Healing").getBoolean(Constants.DEF_HEALING);
	Constants.DEF_SNOWSTEP = config.get(CATEGORY_FUNCTION, "SnowStep", Constants.DEF_SNOWSTEP).setLanguageKey(Constants.guiKey + "SnowStep").getBoolean(Constants.DEF_SNOWSTEP);
	Constants.DEF_GRASSSTEP = config.get(CATEGORY_FUNCTION, "GrassStep", Constants.DEF_GRASSSTEP).setLanguageKey(Constants.guiKey + "GrassStep").getBoolean(Constants.DEF_GRASSSTEP);

	//@formatter:off
	/*=================================Miscellaneous Configurations==========================================*/
	//@formatter:on

	Constants.DEF_HOWL = config.get(CATEGORY_MISC, "Howl", Constants.DEF_HOWL).setLanguageKey(Constants.guiKey + "Howl").getBoolean(Constants.DEF_HOWL);
	Constants.DEF_IS_HUNGER_ON = config.get(CATEGORY_MISC, "HungerDecay", Constants.DEF_IS_HUNGER_ON).setLanguageKey(Constants.guiKey + "HungerDecay").getBoolean(Constants.DEF_IS_HUNGER_ON);

	//@formatter:off
	/*=================================DimensionsConfigurations==========================================*/
	//@formatter:on

	IDs.Nillax = config.get(CATEGORY_DIMENSION, "NillaxID", IDs.Nillax).setLanguageKey(Constants.guiKey + "NillaxID").setRequiresMcRestart(true).getInt(IDs.Nillax);
	if (Constants.DEF_DARKLOAD == true) {
		IDs.Darkax = config.get(CATEGORY_DIMENSION, "DarkaxID", IDs.Darkax).setLanguageKey(Constants.guiKey + "DarkaxID").setRequiresMcRestart(true).getInt(IDs.Darkax);
	}

	//@formatter:off
	/*=================================BiomesConfigurations==========================================*/
	//@formatter:on
	IDs.bioZone = config.get(CATEGORY_BIOME, "BioZoneID", IDs.bioZone).setLanguageKey(Constants.guiKey + "BioZoneID").setRequiresMcRestart(true).getInt(IDs.bioZone);
	IDs.redSeed = config.get(CATEGORY_BIOME, "RedSeedID", IDs.redSeed).setLanguageKey(Constants.guiKey + "RedSeedID").setRequiresMcRestart(true).getInt(IDs.redSeed);
	IDs.blueTaiga = config.get(CATEGORY_BIOME, "BlueTaigaID", IDs.blueTaiga).setLanguageKey(Constants.guiKey + "BlueTaigaID").setRequiresMcRestart(true).getInt(IDs.blueTaiga);
	IDs.blueTaigaHills = config.get(CATEGORY_BIOME, "BlueTaigaHillsID", IDs.blueTaigaHills).setLanguageKey(Constants.guiKey + "BlueTaigaHillsID").setRequiresMcRestart(true).getInt(IDs.blueTaigaHills);
	IDs.blueColdTaiga = config.get(CATEGORY_BIOME, "BlueColdTaigaID", IDs.blueColdTaiga).setLanguageKey(Constants.guiKey + "BlueColdTaigaID").setRequiresMcRestart(true).getInt(IDs.blueColdTaiga);
	IDs.blueColdTaigaHills = config.get(CATEGORY_BIOME, "BlueColdTaigaHillsID", IDs.blueColdTaigaHills).setLanguageKey(Constants.guiKey + "BlueColdTaigaHillsID").setRequiresMcRestart(true).getInt(IDs.blueColdTaigaHills);
	IDs.blueMegaTaiga = config.get(CATEGORY_BIOME, "BlueMegaTaigaID", IDs.blueMegaTaiga).setLanguageKey(Constants.guiKey + "BlueMegaTaigaID").setRequiresMcRestart(true).getInt(IDs.blueMegaTaiga);
	IDs.blueMegaTaigaHills = config.get(CATEGORY_BIOME, "BlueMegaTaigaHillsID", IDs.blueMegaTaigaHills).setLanguageKey(Constants.guiKey + "BlueMegaTaigaHillsID").setRequiresMcRestart(true).getInt(IDs.blueMegaTaigaHills);
	IDs.pinkZone = config.get(CATEGORY_BIOME, "PinkZoneID", IDs.pinkZone).setLanguageKey(Constants.guiKey + "PinkZoneID").setRequiresMcRestart(true).getInt(IDs.pinkZone);
	IDs.destroZone = config.get(CATEGORY_BIOME, "DestroZoneID", IDs.destroZone).setLanguageKey(Constants.guiKey + "DestroZoneID").setRequiresMcRestart(true).getInt(IDs.destroZone);
	IDs.destroZoneHills = config.get(CATEGORY_BIOME, "DestroZoneHillsID", IDs.destroZoneHills).setLanguageKey(Constants.guiKey + "DestroZoneHillsID").setRequiresMcRestart(true).getInt(IDs.destroZoneHills);
	IDs.walRockland = config.get(CATEGORY_BIOME, "WalRocklandID", IDs.walRockland).setLanguageKey(Constants.guiKey + "WalRocklandID").setRequiresMcRestart(true).getInt(IDs.walRockland);
	if (Constants.DEF_DARKLOAD == true) {
		IDs.darkWasteland = config.get(CATEGORY_BIOME, "DarkaxBiomeID", IDs.darkWasteland).setLanguageKey(Constants.guiKey + "DarkaxBiomeID").setRequiresMcRestart(true).getInt(IDs.darkWasteland);
	}
	IDs.nileSavanna = config.get(CATEGORY_BIOME, "NileSavannaID", IDs.nileSavanna).setLanguageKey(Constants.guiKey + "NileSavannaID").setRequiresMcRestart(true).getInt(IDs.nileSavanna);
	IDs.nileSavannaPlateau = config.get(CATEGORY_BIOME, "NileSavannaPlateauID", IDs.nileSavannaPlateau).setLanguageKey(Constants.guiKey + "NileSavannaPlateauID").setRequiresMcRestart(true).getInt(IDs.nileSavannaPlateau);
	IDs.nileJungle = config.get(CATEGORY_BIOME, "NileJungleID", IDs.nileJungle).setLanguageKey(Constants.guiKey + "NileJungleID").setRequiresMcRestart(true).getInt(IDs.nileJungle);
	IDs.nileJungleHills = config.get(CATEGORY_BIOME, "NileJungleHillsID", IDs.nileJungleHills).setLanguageKey(Constants.guiKey + "NileJungleHillsID").setRequiresMcRestart(true).getInt(IDs.nileJungleHills);
	IDs.nileJungleEdge = config.get(CATEGORY_BIOME, "NileJungleEdgeID", IDs.nileJungleEdge).setLanguageKey(Constants.guiKey + "NileJungleEdgeID").setRequiresMcRestart(true).getInt(IDs.nileJungleEdge);
	IDs.nileSwampland = config.get(CATEGORY_BIOME, "NileSwamplandID", IDs.nileSwampland).setLanguageKey(Constants.guiKey + "NileSwamplandID").setRequiresMcRestart(true).getInt(IDs.nileSwampland);
	IDs.nileMesa = config.get(CATEGORY_BIOME, "NileMesaID", IDs.nileMesa).setLanguageKey(Constants.guiKey + "NileMesaID").setRequiresMcRestart(true).getInt(IDs.nileMesa);
	IDs.nileMesaPlateau_F = config.get(CATEGORY_BIOME, "NileMesaPlateauFID", IDs.nileMesaPlateau_F).setLanguageKey(Constants.guiKey + "NileMesaPlateauFID").setRequiresMcRestart(true).getInt(IDs.nileMesaPlateau_F);
	IDs.nileMesaPlateau = config.get(CATEGORY_BIOME, "NileMesaPlateauID", IDs.nileMesaPlateau).setLanguageKey(Constants.guiKey + "NileMesaPlateauID").setRequiresMcRestart(true).getInt(IDs.nileMesaPlateau);
	IDs.nileMountains = config.get(CATEGORY_BIOME, "NileMountainsID", IDs.nileMountains).setLanguageKey(Constants.guiKey + "NileMountainsID").setRequiresMcRestart(true).getInt(IDs.nileMountains);
	IDs.nileMountainsEdge = config.get(CATEGORY_BIOME, "NileMountainsEdgeID", IDs.nileMountainsEdge).setLanguageKey(Constants.guiKey + "NileMountainsEdgeID").setRequiresMcRestart(true).getInt(IDs.nileMountainsEdge);
	IDs.nileMountainsPlus = config.get(CATEGORY_BIOME, "NileMountainsPlusID", IDs.nileMountainsPlus).setLanguageKey(Constants.guiKey + "NileMountainsPlusID").setRequiresMcRestart(true).getInt(IDs.nileMountainsPlus);

	if (config.hasChanged()) {
		config.save();
	}
}
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.