// Path: src/main/java/mods/belgabor/amtweaker/AMTweaker.java
// @Mod(modid = AMTweaker.MODID, version = AMTweaker.VERSION, name = "AMTweaker", dependencies = "required-after:MineTweaker3;after:DCsAppleMilk;after:ModTweaker;after:AWWayofTime;after:DCsEcoMT;after:mceconomy2")
// public class AMTweaker implements IEventHandler<MineTweakerImplementationAPI.ReloadEvent>
// {
//     public static final String MODID = "AMTweaker";
//     public static final String VERSION = "1.0";
//     
//     @Mod.Instance(MODID)
//     public static AMTweaker INSTANCE;
//     
//     public static File confDir;
//     public static File logsDir;
//     public static Logger logger;
//     public static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
// 
//     public static void log(Level level, String message, Object ... args) {
//         logger.log(level, String.format(message, args));
//     }
//     
//     @EventHandler
//     public void preInit(FMLPreInitializationEvent event)
//     {
//         logger = event.getModLog();
//         confDir = new File(event.getModConfigurationDirectory(), "AMTweaker/");
//         logsDir = new File("logs/");
//         
//         Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
//         try {
//             cfg.load();
//             
//             cfg.setCategoryComment(SS2.MODID, "Sextiary Sector 2 specific options");
//             
//             SS2.configIEHeatFurnaces = cfg.getBoolean("IEHeatFurnaces", SS2.MODID, SS2.configIEHeatFurnaces, 
//                     "Allow the Immersive Engineering Furnace Heater to heat the Fluid and Large Furnace");
//             SS2.configIEHeatSmokers = cfg.getBoolean("IEHeatSmokers", SS2.MODID, SS2.configIEHeatSmokers,
//                     "Allow the Immersive Engineering Furnace Heater to heat the Food Smokers");
//         } catch (Exception e) {
//             e.printStackTrace();
//         } finally {
//             if (cfg.hasChanged())
//                 cfg.save();
//         }
// 
//         if (Loader.isModLoaded(EMT.MODID)) {
//             ensureConfDir();
//             EMTConfiguration.read();
//         }
//     }
// 
//     @EventHandler
//     public void init(FMLInitializationEvent event)
//     {
//         new Vanilla();
//         TweakerPlugin.register(AMT.MODID, AMT.class);
//         TweakerPlugin.register(EMT.MODID, EMT.class);
//         TweakerPlugin.register(MCE.MODID, MCE.class);
//         TweakerPlugin.register(SS2.MODID, SS2.class);
//     }
// 
//     @EventHandler
//     public void postInit(FMLPostInitializationEvent event)
//     {
//         if (Loader.isModLoaded(EMT.MODID)) {
//             EMTConfiguration.apply();
//         }
//     }
// 
//     @EventHandler
//     public void onServerStart(FMLServerStartingEvent event) {
//         registerCommands();
//         registerLoggers();
//         MineTweakerImplementationAPI.onReloadEvent(this);
//     }
// 
//     private void registerCommands() {
//         MinecraftServer server = MinecraftServer.getServer();
//         ICommandManager command = server.getCommandManager();
//         ServerCommandManager manager = (ServerCommandManager) command;
//         manager.registerCommand(new VanillaCommandBlockstats());        
//     }
// 
//     public void handle(MineTweakerImplementationAPI.ReloadEvent event) {
//         registerLoggers();
//     }
// 
//     private void ensureConfDir() {
//         if (!confDir.exists()) {
//             //noinspection ResultOfMethodCallIgnored
//             confDir.mkdirs();
//         }
//     }
// 
//     private void registerLoggers() {
//         VanillaCommandLoggerItem.register();
//         if (Loader.isModLoaded(AMT.MODID))
//             AMTCommandLogger.register();
//         if (Loader.isModLoaded(CW2.MODID))
//             CW2CommandLogger.register();
//         if (Loader.isModLoaded(EMT.MODID))
//             EMTCommandLogger.register();
//         if (Loader.isModLoaded(MCE.MODID))
//             MCECommandLogger.register();
//         if (Loader.isModLoaded(SS2.MODID))
//             SS2CommandLogger.register();
//     }
// }


import com.google.gson.JsonElement;
import defeatedcrow.addonforamt.economy.api.RecipeManagerEMT;
import defeatedcrow.addonforamt.economy.api.order.IOrder;
import defeatedcrow.addonforamt.economy.api.order.OrderBiome;
import defeatedcrow.addonforamt.economy.api.order.OrderSeason;
import defeatedcrow.addonforamt.economy.api.order.OrderType;
import mods.belgabor.amtweaker.AMTweaker;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
                AMTweaker.log(Level.WARN, "Ignoring malformed order entry for item '%s': Invalid biome type '%s'.", order.request, order.biome);
                continue;
            }
            if (order.name.equals("")) {
                AMTweaker.log(Level.WARN, "Ignoring malformed order entry for item '%s': No name given.", order.request);
                continue;
            }

            RecipeManagerEMT.orderRegister.addRecipe(request, order.amount, order.reward, type, season, biome, order.name);
            a++;
        }
        AMTweaker.log(Level.INFO, "%d/%d EMT orders added successfully", a, b);
    }

    private static void addDump(List<OrderData> dumps, List<? extends IOrder> source) {
        for(IOrder order : source) {
            dumps.add(new OrderData(order));
        }
    }

    public static boolean dump() {
        ArrayList<OrderData> dumps = new ArrayList<>();
        addDump(dumps, RecipeManagerEMT.orderRegister.getSingleOrders());
        addDump(dumps, RecipeManagerEMT.orderRegister.getShortOrders());
        addDump(dumps, RecipeManagerEMT.orderRegister.getMiddleOrders());
        addDump(dumps, RecipeManagerEMT.orderRegister.getLongOrders());

        File emtDump = new File(AMTweaker.confDir, "emt-dump.json");
        try {
            FileWriter f = new FileWriter(emtDump, false);
// Path: src/main/java/mods/belgabor/amtweaker/AMTweaker.java
// @Mod(modid = AMTweaker.MODID, version = AMTweaker.VERSION, name = "AMTweaker", dependencies = "required-after:MineTweaker3;after:DCsAppleMilk;after:ModTweaker;after:AWWayofTime;after:DCsEcoMT;after:mceconomy2")
// public class AMTweaker implements IEventHandler<MineTweakerImplementationAPI.ReloadEvent>
// {
//     public static final String MODID = "AMTweaker";
//     public static final String VERSION = "1.0";
//     
//     @Mod.Instance(MODID)
//     public static AMTweaker INSTANCE;
//     
//     public static File confDir;
//     public static File logsDir;
//     public static Logger logger;
//     public static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
// 
//     public static void log(Level level, String message, Object ... args) {
//         logger.log(level, String.format(message, args));
//     }
//     
//     @EventHandler
//     public void preInit(FMLPreInitializationEvent event)
//     {
//         logger = event.getModLog();
//         confDir = new File(event.getModConfigurationDirectory(), "AMTweaker/");
//         logsDir = new File("logs/");
//         
//         Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
//         try {
//             cfg.load();
//             
//             cfg.setCategoryComment(SS2.MODID, "Sextiary Sector 2 specific options");
//             
//             SS2.configIEHeatFurnaces = cfg.getBoolean("IEHeatFurnaces", SS2.MODID, SS2.configIEHeatFurnaces, 
//                     "Allow the Immersive Engineering Furnace Heater to heat the Fluid and Large Furnace");
//             SS2.configIEHeatSmokers = cfg.getBoolean("IEHeatSmokers", SS2.MODID, SS2.configIEHeatSmokers,
//                     "Allow the Immersive Engineering Furnace Heater to heat the Food Smokers");
//         } catch (Exception e) {
//             e.printStackTrace();
//         } finally {
//             if (cfg.hasChanged())
//                 cfg.save();
//         }
// 
//         if (Loader.isModLoaded(EMT.MODID)) {
//             ensureConfDir();
//             EMTConfiguration.read();
//         }
//     }
// 
//     @EventHandler
//     public void init(FMLInitializationEvent event)
//     {
//         new Vanilla();
//         TweakerPlugin.register(AMT.MODID, AMT.class);
//         TweakerPlugin.register(EMT.MODID, EMT.class);
//         TweakerPlugin.register(MCE.MODID, MCE.class);
//         TweakerPlugin.register(SS2.MODID, SS2.class);
//     }
// 
//     @EventHandler
//     public void postInit(FMLPostInitializationEvent event)
//     {
//         if (Loader.isModLoaded(EMT.MODID)) {
//             EMTConfiguration.apply();
//         }
//     }
// 
//     @EventHandler
//     public void onServerStart(FMLServerStartingEvent event) {
//         registerCommands();
//         registerLoggers();
//         MineTweakerImplementationAPI.onReloadEvent(this);
//     }
// 
//     private void registerCommands() {
//         MinecraftServer server = MinecraftServer.getServer();
//         ICommandManager command = server.getCommandManager();
//         ServerCommandManager manager = (ServerCommandManager) command;
//         manager.registerCommand(new VanillaCommandBlockstats());        
//     }
// 
//     public void handle(MineTweakerImplementationAPI.ReloadEvent event) {
//         registerLoggers();
//     }
// 
//     private void ensureConfDir() {
//         if (!confDir.exists()) {
//             //noinspection ResultOfMethodCallIgnored
//             confDir.mkdirs();
//         }
//     }
// 
//     private void registerLoggers() {
//         VanillaCommandLoggerItem.register();
//         if (Loader.isModLoaded(AMT.MODID))
//             AMTCommandLogger.register();
//         if (Loader.isModLoaded(CW2.MODID))
//             CW2CommandLogger.register();
//         if (Loader.isModLoaded(EMT.MODID))
//             EMTCommandLogger.register();
//         if (Loader.isModLoaded(MCE.MODID))
//             MCECommandLogger.register();
//         if (Loader.isModLoaded(SS2.MODID))
//             SS2CommandLogger.register();
//     }
// }


// Path: src/main/java/mods/belgabor/amtweaker/mods/emt/configuration/EMTConfiguration.java
import com.google.gson.JsonElement;
import defeatedcrow.addonforamt.economy.api.RecipeManagerEMT;
import defeatedcrow.addonforamt.economy.api.order.IOrder;
import defeatedcrow.addonforamt.economy.api.order.OrderBiome;
import defeatedcrow.addonforamt.economy.api.order.OrderSeason;
import defeatedcrow.addonforamt.economy.api.order.OrderType;
import mods.belgabor.amtweaker.AMTweaker;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

                AMTweaker.log(Level.WARN, "Ignoring malformed order entry for item '%s': Invalid biome type '%s'.", order.request, order.biome);
                continue;
            }
            if (order.name.equals("")) {
                AMTweaker.log(Level.WARN, "Ignoring malformed order entry for item '%s': No name given.", order.request);
                continue;
            }

            RecipeManagerEMT.orderRegister.addRecipe(request, order.amount, order.reward, type, season, biome, order.name);
            a++;
        }
        AMTweaker.log(Level.INFO, "%d/%d EMT orders added successfully", a, b);
    }

    private static void addDump(List<OrderData> dumps, List<? extends IOrder> source) {
        for(IOrder order : source) {
            dumps.add(new OrderData(order));
        }
    }

    public static boolean dump() {
        ArrayList<OrderData> dumps = new ArrayList<>();
        addDump(dumps, RecipeManagerEMT.orderRegister.getSingleOrders());
        addDump(dumps, RecipeManagerEMT.orderRegister.getShortOrders());
        addDump(dumps, RecipeManagerEMT.orderRegister.getMiddleOrders());
        addDump(dumps, RecipeManagerEMT.orderRegister.getLongOrders());

        File emtDump = new File(AMTweaker.confDir, "emt-dump.json");
        try {
            FileWriter f = new FileWriter(emtDump, false);
            AMTweaker.gson.toJson(dumps, f);