/*
 ** 2013 April 09
 **
 ** The author disclaims copyright to this source code.  In place of
 ** a legal notice, here is a blessing:
 **    May you do good and not evil.
 **    May you find forgiveness for yourself and forgive others.
 **    May you share freely, never taking more than you give.
 */
package info.ata4.minecraft.minema;

import java.io.File;

import info.ata4.minecraft.minema.client.cmd.CommandMinema;
import info.ata4.minecraft.minema.client.config.MinemaConfig;
import info.ata4.minecraft.minema.client.modules.CaptureSession;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.ModMetadata;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.EventBus;

/**
 * Main control class for Forge.
 *
 * @author Nico Bergemann <barracuda415 at yahoo.de>
 */
@Mod(modid = Minema.ID, name = Minema.NAME, version = Minema.VERSION, guiFactory = "info.ata4.minecraft.minema.client.config.MinemaConfigGuiFactory")
public class Minema {

	public static final String NAME = "Minema";
	/*
	 * in 1.11 Forge will only accept a lower case id and due to annotations
	 * this has to be a constant expression
	 */
	public static final String ID = "minema";
	public static final String VERSION = "1.10.2";

	@Instance(ID)
	public static Minema instance;
	public static final EventBus EVENT_BUS = new EventBus();

	private ModMetadata metadata;
	private Configuration configForge;
	private MinemaConfig config;
	private CaptureSession session;

	@EventHandler
	public void onPreInit(FMLPreInitializationEvent evt) {
		File file = evt.getSuggestedConfigurationFile();
		configForge = new Configuration(file);
		config = new MinemaConfig(configForge);
		metadata = evt.getModMetadata();
	}

	@EventHandler
	public void onInit(FMLInitializationEvent evt) {
		ClientCommandHandler.instance.registerCommand(new CommandMinema(this));
		MinecraftForge.EVENT_BUS.register(new KeyHandler(this));
	}

	public Configuration getConfigForge() {
		return configForge;
	}

	public MinemaConfig getConfig() {
		return config;
	}

	public ModMetadata getMetadata() {
		return metadata;
	}

	public void enable() {
		session = new CaptureSession(config);
		session.enable();
	}

	public void disable() {
		if (isEnabled()) {
			session.disable();
		}
		session = null;
	}

	public boolean isEnabled() {
		return session != null && session.isEnabled();
	}
}

@@ -696,24 +696,87 @@
 figuration;%0A
+import net.minecraftforge.fml.client.event.ConfigChangedEvent;%0A
 import net.m
@@ -2369,24 +2369,197 @@
 this));%0A%09%7D%0A%0A
+%09@EventHandler%0A%09public void onConfigChanged(ConfigChangedEvent e) %7B%0A%09%09if (e.getModID().equals(ID)) %7B%0A%09%09%09if (configForge.hasChanged()) %7B%0A%09%09%09%09configForge.save();%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A
 %09public Conf

Reimplement basic save mechanism