// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
//     public static final String MODID = "chinacraft";
//     public static final String NAME = "ChinaCraft 2";
//     public static final String VERSION = "0.0.1";
// 
//     @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
//     private static CommonProxy proxy;
// 
//     @Mod.Instance(ChinaCraft.MODID)
//     private static ChinaCraft instance;
// 
//     private CCEventHandler eventHandler;
// 
//     private static SimpleNetworkWrapper network;
// 
//     private static final Logger LOGGER = LogManager.getLogger(MODID);
// 
//     private JsonSettings settings;
// 
//     @EventHandler
//     public void preInit(FMLPreInitializationEvent event) {
//         settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
//         proxy.preInit(event);
//         eventHandler = new CCEventHandler();
//     }
// 
//     @EventHandler
//     public void init(FMLInitializationEvent event) {
//         network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
//         network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
// 
//         NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
// 
//         proxy.init(event);
//     }
// 
//     @EventHandler
//     public void postInit(FMLPostInitializationEvent event) {
//         proxy.postInit(event);
//     }
// 
//     @EventHandler
//     public void loadComplete(FMLLoadCompleteEvent event) {
//         proxy.loadComplete(event);
//     }
// 
//     public JsonSettings getSettings() {
//         return settings;
//     }
// 
//     public CCEventHandler getEventHandler() {
//         return eventHandler;
//     }
// 
//     public static Logger getLogger() {
//         return LOGGER;
//     }
// 
//     public static ChinaCraft getInstance() {
//         return instance;
//     }
// 
//     public static SimpleNetworkWrapper getNetwork() {
//         return network;
//     }
// 
//     public static CommonProxy getProxy() {
//         return proxy;
//     }
// }


import cn.mccraft.chinacraft.common.ChinaCraft;
import net.minecraftforge.fml.common.LoaderState;
import net.minecraftforge.fml.common.event.FMLStateEvent;
import net.minecraftforge.fml.relauncher.Side;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
package cn.mccraft.util.loader;



/**
 * 动态代理.
 * 请在主类中监听你要进行注册的{@link FMLStateEvent} 并调用{@link #invoke(FMLStateEvent, LoaderState, Side)}函数.
 *
 */
public interface Proxy {
    default <T extends FMLStateEvent> void invoke (T event, LoaderState state, Side side) {
        getStateLoaderMap().values().forEach(methods -> methods.forEach(method -> {
            if (method.getAnnotation(Load.class).side().equals(side))
                if (method.getParameterCount() == 0 && method.getAnnotation(Load.class).value().equals(state))
                    try {
                        method.invoke(getLoaderInstanceMap().get(method.getDeclaringClass()));
                    } catch (IllegalAccessException | InvocationTargetException e) {
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
//     public static final String MODID = "chinacraft";
//     public static final String NAME = "ChinaCraft 2";
//     public static final String VERSION = "0.0.1";
// 
//     @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
//     private static CommonProxy proxy;
// 
//     @Mod.Instance(ChinaCraft.MODID)
//     private static ChinaCraft instance;
// 
//     private CCEventHandler eventHandler;
// 
//     private static SimpleNetworkWrapper network;
// 
//     private static final Logger LOGGER = LogManager.getLogger(MODID);
// 
//     private JsonSettings settings;
// 
//     @EventHandler
//     public void preInit(FMLPreInitializationEvent event) {
//         settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
//         proxy.preInit(event);
//         eventHandler = new CCEventHandler();
//     }
// 
//     @EventHandler
//     public void init(FMLInitializationEvent event) {
//         network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
//         network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
// 
//         NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
// 
//         proxy.init(event);
//     }
// 
//     @EventHandler
//     public void postInit(FMLPostInitializationEvent event) {
//         proxy.postInit(event);
//     }
// 
//     @EventHandler
//     public void loadComplete(FMLLoadCompleteEvent event) {
//         proxy.loadComplete(event);
//     }
// 
//     public JsonSettings getSettings() {
//         return settings;
//     }
// 
//     public CCEventHandler getEventHandler() {
//         return eventHandler;
//     }
// 
//     public static Logger getLogger() {
//         return LOGGER;
//     }
// 
//     public static ChinaCraft getInstance() {
//         return instance;
//     }
// 
//     public static SimpleNetworkWrapper getNetwork() {
//         return network;
//     }
// 
//     public static CommonProxy getProxy() {
//         return proxy;
//     }
// }


// Path: src/main/extern/cn/mccraft/util/loader/Proxy.java
import cn.mccraft.chinacraft.common.ChinaCraft;
import net.minecraftforge.fml.common.LoaderState;
import net.minecraftforge.fml.common.event.FMLStateEvent;
import net.minecraftforge.fml.relauncher.Side;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;

package cn.mccraft.util.loader;



/**
 * 动态代理.
 * 请在主类中监听你要进行注册的{@link FMLStateEvent} 并调用{@link #invoke(FMLStateEvent, LoaderState, Side)}函数.
 *
 */
public interface Proxy {
    default <T extends FMLStateEvent> void invoke (T event, LoaderState state, Side side) {
        getStateLoaderMap().values().forEach(methods -> methods.forEach(method -> {
            if (method.getAnnotation(Load.class).side().equals(side))
                if (method.getParameterCount() == 0 && method.getAnnotation(Load.class).value().equals(state))
                    try {
                        method.invoke(getLoaderInstanceMap().get(method.getDeclaringClass()));
                    } catch (IllegalAccessException | InvocationTargetException e) {
                        ChinaCraft.getLogger().warn("Un-able to invoke method " + method.getName(), e);