package com.tikaji.halocraft;

import com.tikaji.halocraft.common.handlers.ConfigurationHandler;
import com.tikaji.halocraft.common.proxy.IProxy;
import com.tikaji.halocraft.common.utility.Reference;
import com.tikaji.halocraft.common.utility.VersionChecker;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

/**
 * Created by Jacob Williams on 6/17/2015.
 */
@Mod(modid = Reference.ModInfo.MOD_ID, name = Reference.ModInfo.MOD_NAME, version = Reference.ModInfo.VERSION)
public class HaloCraft
{
	@Mod.Instance
	public static HaloCraft INSTANCE;
	public static boolean haveWarnedVersionIsOutOfDate = false;
	@SidedProxy(clientSide = Reference.ModInfo.CLIENT_PROXY_CLASS, serverSide = Reference.ModInfo.SERVER_PROXY_CLASS)
	public static IProxy         proxy;
	public static VersionChecker versionChecker;

	public static String prependModID(String name)
	{
		return Reference.ModInfo.MOD_ID + ":" + name;
	}

	@Mod.EventHandler
	public void initialize(FMLInitializationEvent event)
	{
		proxy.init();
	}

	@Mod.EventHandler
	public void postInit(FMLPostInitializationEvent event)
	{
		proxy.postInit();
		ConfigurationHandler.postInit();
	}

	@Mod.EventHandler
	public void preInit(FMLPreInitializationEvent event)
	{
		ConfigurationHandler.init(new Configuration(event.getSuggestedConfigurationFile()));
		proxy.preInit();
		ConfigurationHandler.save();
	}
}
