package frogcraftrebirth.common.lib.config;

import java.io.File;

import frogcraftrebirth.api.FrogAPI;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

public class ConfigMain {
	
	static Configuration config;

	public static double railgunDamageScale;
	public static int airPumpPowerRate;
	public static int airPumpGenerateSpeed;
	public static int combustionFurnacePowerRate;
	
	@Deprecated
	public static boolean enableTCAspect;

	public static boolean enableAccessControl;

	public static boolean enableModpackCreationMode;
	public static boolean enableClassicMode;
	
	public static void init(FMLPreInitializationEvent event) {
		File configDir = new File(event.getModConfigurationDirectory(), FrogAPI.MODID);
		
		if (!configDir.exists())
			configDir.mkdirs();
		ConfigMain.initMainConfig(new File(configDir, "FrogMain.cfg"));
		
		File reactionDir = new File(configDir, "reactions");
		if (!reactionDir.exists())
			reactionDir.mkdirs(); // This is left for legacy reasons.
	}
	
	public static void initMainConfig(File file) {
		config = new Configuration(file);
		
		config.load();
		
		enableModpackCreationMode = config.getBoolean("EnableModpackCreationMode", "General", false, "Set this to ture will let FrogCraft: Rebirth not loading any recipes, providing convenience for modpack creators.", "frogcraft.config.general.modpack");
		enableClassicMode = config.get("General", "EnableClassicMode", false).getBoolean();
		
		airPumpPowerRate = config.get("Machine", "AirPumpPowerRate", 120).getInt();
		airPumpGenerateSpeed = config.get("Machine", "AirPumpGenerateSpeed", 50).getInt();
		combustionFurnacePowerRate = config.get("Machine", "CombustionFurnacePowerRate", 10).getInt();
		
		railgunDamageScale = config.getFloat("RailgunDamageScale", "Misc", 100, Double.MIN_EXPONENT, Double.MAX_EXPONENT, null, "frogcraft.config.railgunDamageScale");

		enableTCAspect = config.get("Compatibility", "addAspectIntoItems", true).getBoolean();
		
		enableAccessControl = config.get("Access Control", "EnableAccessControl", false).getBoolean();
		
		if (config.hasChanged())
			config.save();
	}
	
}

@@ -230,16 +230,22 @@
 %0Apublic 
+final 
 class Co
@@ -257,16 +257,124 @@
 ain %7B%0A%09%0A
+%09private ConfigMain() %7B%0A%09%09throw new UnsupportedOperationException();%0A%09%7D%0A%09%0A%09//Require a thorough clean up%09%0A%09%0A
 %09static 
@@ -898,18 +898,16 @@
 .MODID);
-%0A%09
 %09%0A%09%09if (
@@ -1021,167 +1021,20 @@
 );%0A%09
-%09%0A%09%09File reactionDir = new File(configDir, %22reactions%22);%0A%09%09if (!reactionDir.exists())%0A%09%09%09reactionDir.mkdirs(); // This is left for legacy reasons.%0A%09%7D%0A%09%0A%09public
+%7D%0A%09%0A%09private
  sta
@@ -1440,32 +1440,36 @@
 ssicMode%22, false
+, %22%22
 ).getBoolean();%0A

Mark ConfigMain as awaitng for overhaul