package ljfa.tntutils;

import java.io.File;

import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class Config {
    public static Configuration conf;

    public static final String CATEGORY_GENERAL = "general";
    
    public static boolean replaceTNT;
    public static boolean explosionCommand;
    
    public static void loadConfig(File file) {
        if(conf == null)
            conf = new Configuration(file);
        
        conf.load();
        loadValues();
        
        FMLCommonHandler.instance().bus().register(new ChangeHandler());
    }
    
    public static void loadValues() {
        replaceTNT = conf.getBoolean("preventChainExplosions", CATEGORY_GENERAL, true, "Prevent explosions from triggering TNT");
        explosionCommand = conf.getBoolean("addExplosionCommand", CATEGORY_GENERAL, true, "Adds the \"/explosion\" command");
        //----------------
        if(conf.hasChanged())
            conf.save();
    }
    
    /** Reloads the config values upon change */
    public static class ChangeHandler {
        @SubscribeEvent
        public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
            if(event.modID.equals(Reference.MODID))
                loadValues();
        }
    }
}

@@ -37,16 +37,64 @@
 io.File;
+%0Aimport java.util.HashSet;%0Aimport java.util.Set;
 %0A%0Aimport
@@ -142,16 +142,55 @@
 ration;%0A
+import scala.actors.threadpool.Arrays;%0A
 import c
@@ -545,16 +545,102 @@
 ommand;%0A
+    public static boolean spareTileEntities;%0A    public static Set%3CString%3E blacklist;%0A
     %0A   
@@ -1061,24 +1061,24 @@
 ring TNT%22);%0A
-
         expl
@@ -1187,24 +1187,382 @@
  command%22);%0A
+        spareTileEntities = conf.getBoolean(%22spareTileEntites%22, CATEGORY_GENERAL, false, %22Makes explosions not destroy tile entities%22);%0A        blacklist = new HashSet%3CString%3E(Arrays.asList(%0A            conf.getStringList(%22destructionBlacklist%22, CATEGORY_GENERAL, new String%5B0%5D, %22A list of blocks that will never be destroyed by explosions%22)%0A            ));%0A
         //--

Add some configs