/*
 ** 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.KeyHandler;
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.client.event.ConfigChangedEvent;
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.SubscribeEvent;

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

	public static final String NAME = "Minema";
	public static final String ID = NAME;
	public static final String AID = NAME.toLowerCase();
	public static final String VERSION = "1.9";

	@Instance(ID)
	public static Minema instance;

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

	public MinemaConfig getConfig() {
		return config;
	}

	public ModMetadata getMetadata() {
		return metadata;
	}

	public void enable() {
		config.load();

		session = new CaptureSession(config);
		session.enable();
	}

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

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

	@SubscribeEvent
	public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) {
		if (eventArgs.modID.equals(ID)) {
			config.update(false);
		}
	}

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

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

@@ -1389,28 +1389,8 @@
 ION,
- useMetadata = true,
  gui
@@ -1473,16 +1473,22 @@
 %0Apublic 
+final 
 class Mi
@@ -1583,62 +1583,8 @@
 ME;%0A
-%09public static final String AID = NAME.toLowerCase();%0A
 %09pub
@@ -1768,16 +1768,476 @@
 ssion;%0A%0A
+%09@EventHandler%0A%09public void onPreInit(FMLPreInitializationEvent evt) %7B%0A%09%09File file = evt.getSuggestedConfigurationFile();%0A%09%09config = new MinemaConfig(new Configuration(file));%0A%09%09metadata = evt.getModMetadata();%0A%09%7D%0A%0A%09@EventHandler%0A%09public void onInit(FMLInitializationEvent evt) %7B%0A%09%09ClientCommandHandler.instance.registerCommand(new CommandMinema(this));%0A%09%09MinecraftForge.EVENT_BUS.register(new KeyHandler(this));%0A%09%09MinecraftForge.EVENT_BUS.register(this);%0A%09%7D%0A%0A
 %09public 
@@ -2798,465 +2798,6 @@
 %09%7D%0A%0A
-%09@EventHandler%0A%09public void onPreInit(FMLPreInitializationEvent evt) %7B%0A%09%09File file = evt.getSuggestedConfigurationFile();%0A%09%09config = new MinemaConfig(new Configuration(file));%0A%09%09metadata = evt.getModMetadata();%0A%09%7D%0A%0A%09@EventHandler%0A%09public void onInit(FMLInitializationEvent evt) %7B%0A%09%09ClientCommandHandler.instance.registerCommand(new CommandMinema(this));%0A%09%09MinecraftForge.EVENT_BUS.register(new KeyHandler(this));%0A%09%09MinecraftForge.EVENT_BUS.register(this);%0A%09%7D%0A
 %7D%0A

Tidy up main class