package me.markeh.massivecoreforgefixes;

import me.markeh.massivecoreforgefixes.plugins.FixBase;
import me.markeh.massivecoreforgefixes.plugins.factions.FactionsFixes;

import org.bukkit.ChatColor;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;

public class MassiveCoreForgeFixes extends JavaPlugin {

	// ------------------------------
	//  SINGLETON
	// ------------------------------
	
	private static MassiveCoreForgeFixes i;
	public static MassiveCoreForgeFixes get() { return i; }
	public MassiveCoreForgeFixes() { i = this; }
	
	// ------------------------------
	//  PLUGIN ENABLE
	// ------------------------------
	
	@Override
	public final void onEnable() {
		try
		{
			Class.forName("cpw.mods.fml.common.FMLCommonHandler");
		} catch (ClassNotFoundException e) {
			log("We couldn't actually find FMLCommonHandler, which usually means this isn't a forge-based server..");
			log("We will still log the events anyway, but please ensure this is only running on a forge-based server.");
		}	
		
		if (this.getServer().getPluginManager().isPluginEnabled("MassiveCore") || this.getServer().getPluginManager().isPluginEnabled("MCore")) {
			this.enableFixes();
		} else {
			log("We couldn't find MassiveCore ...");
			this.getServer().getPluginManager().disablePlugin(this);
		}
		
		log("Fixes enabled!");
	}
	
	// ------------------------------
	//  PLUGIN DISABLE
	// ------------------------------

	@Override
	public final void onDisable() {
		this.disableFixes();
	}
	
	// ------------------------------
	//  METHODS
	// ------------------------------
	
	// Simply adds our events 
	public final void enableFixes() {
		this.getServer().getPluginManager().registerEvents(MCFFEvents.get(), this);
		
		if (this.getServer().getPluginManager().isPluginEnabled("Factions")) {
			FactionsFixes.get().enable();
		}
	}
	
	// Simply disables our events and plugin fixes
	public final void disableFixes() {
		HandlerList.unregisterAll(MCFFEvents.get());
		
		FixBase.disableAll();
	}
	
	// Log util
	public final MassiveCoreForgeFixes log(String... msg) {
		for (String m : msg) {
			this.getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[MCFF] " + ChatColor.WHITE + m);
		}
		
		return this;
	}
}

@@ -82,19 +82,30 @@
 plugins.
-Fix
+AbstractPlugin
 Base;%0Aim
@@ -370,24 +370,34 @@
 ------------
+----------
 %0A%09//  SINGLE
@@ -430,24 +430,34 @@
 ------------
+----------
 %0A%09%0A%09private 
@@ -619,32 +619,42 @@
 ----------------
+----------
 %0A%09//  PLUGIN ENA
@@ -687,24 +687,34 @@
 ------------
+----------
 %0A%09%0A%09@Overrid
@@ -752,19 +752,17 @@
  %7B%0A%09%09try
-%0A%09%09
+ 
 %7B%0A%09%09%09Cla
@@ -1422,32 +1422,42 @@
 ----------------
+----------
 %0A%09//  PLUGIN DIS
@@ -1495,16 +1495,26 @@
 --------
+----------
 %0A%0A%09@Over
@@ -1609,24 +1609,34 @@
 ------------
+----------
 %0A%09//  METHOD
@@ -1667,24 +1667,34 @@
 ------------
+----------
 %0A%09%0A%09// Simpl
@@ -2079,19 +2079,30 @@
 );%0A%09%09%0A%09%09
-Fix
+AbstractPlugin
 Base.dis
@@ -2339,10 +2339,12 @@
 his;%0A%09%7D%0A
+%09%0A
 %7D%0A

Tidy up