// Path: src/igwmod/IGWMod.java
// @Mod(modid = Constants.MOD_ID, name = "In-Game Wiki Mod")
// public class IGWMod{
//     @SidedProxy(clientSide = "igwmod.ClientProxy", serverSide = "igwmod.ServerProxy")
//     public static IProxy proxy;
// 
//     @Instance(Constants.MOD_ID)
//     public IGWMod instance;
// 
//     /**
//      * This method is used to reject connection when the server has server info available for IGW-mod. Unless the properties.txt explicitly says
//      * it's okay to connect without IGW-Mod, by setting "optional=true".
//      * @param installedMods
//      * @param side
//      * @return
//      */
//     @NetworkCheckHandler
//     public boolean onConnectRequest(Map<String, String> installedMods, Side side){
//         if(side == Side.SERVER || proxy == null) return true;
//         File serverFolder = new File(proxy.getSaveLocation() + File.separator + "igwmod" + File.separator);
//         if(serverFolder.exists() || new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator).exists()) {//TODO remove legacy
//             String str = proxy.getSaveLocation() + File.separator + "igwmod" + File.separator + "properties.txt";
//             File file = new File(str);
//             if(!file.exists()) {
//                 file = new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator + "properties.txt");//TODO remove legacy
//             }
//             if(file.exists()) {
//                 try {
//                     FileInputStream stream = new FileInputStream(file);
//                     BufferedReader br = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
//                     List<String> textList = new ArrayList<String>();
//                     String line = br.readLine();
//                     while(line != null) {
//                         textList.add(line);
//                         line = br.readLine();
//                     }
//                     br.close();
// 
//                     if(textList != null) {
//                         for(String s : textList) {
//                             String[] entry = s.split("=");
//                             if(entry[0].equals("optional")) {
//                                 if(Boolean.parseBoolean(entry[1])) return true;
//                             }
//                         }
//                     }
//                 } catch(Exception e) {
//                     e.printStackTrace();
//                 }
//             }
//             String version = installedMods.get(Constants.MOD_ID);
//             if(version.equals("${version}")) return true;
//             return version != null && version.equals(Constants.fullVersionString());
//         } else {
//             return true;
//         }
// 
//     }
// 
//     @EventHandler
//     public void preInit(FMLPreInitializationEvent event){
//         event.getModMetadata().version = Constants.fullVersionString();
//         proxy.preInit(event);
//         NetworkHandler.init();
//     }
// 
//     @EventHandler
//     public void init(FMLInitializationEvent event){
// 
//     }
// 
//     @EventHandler
//     public void postInit(FMLPostInitializationEvent event){
//         proxy.postInit();
//     }
// 
//     @EventHandler
//     public void processIMCRequests(FMLInterModComms.IMCEvent event){
//         proxy.processIMC(event);
//     }
// }


import igwmod.IGWMod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.relauncher.Side;
package igwmod.network;


/**
 * 
 * @author MineMaarten
 */
public abstract class AbstractPacket<REQ extends IMessage> implements IMessage, IMessageHandler<REQ, REQ>{

    @Override
    public REQ onMessage(REQ message, MessageContext ctx){

        if(ctx.side == Side.SERVER) {
            handleServerSide(message, ctx.getServerHandler().player);
        } else {
// Path: src/igwmod/IGWMod.java
// @Mod(modid = Constants.MOD_ID, name = "In-Game Wiki Mod")
// public class IGWMod{
//     @SidedProxy(clientSide = "igwmod.ClientProxy", serverSide = "igwmod.ServerProxy")
//     public static IProxy proxy;
// 
//     @Instance(Constants.MOD_ID)
//     public IGWMod instance;
// 
//     /**
//      * This method is used to reject connection when the server has server info available for IGW-mod. Unless the properties.txt explicitly says
//      * it's okay to connect without IGW-Mod, by setting "optional=true".
//      * @param installedMods
//      * @param side
//      * @return
//      */
//     @NetworkCheckHandler
//     public boolean onConnectRequest(Map<String, String> installedMods, Side side){
//         if(side == Side.SERVER || proxy == null) return true;
//         File serverFolder = new File(proxy.getSaveLocation() + File.separator + "igwmod" + File.separator);
//         if(serverFolder.exists() || new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator).exists()) {//TODO remove legacy
//             String str = proxy.getSaveLocation() + File.separator + "igwmod" + File.separator + "properties.txt";
//             File file = new File(str);
//             if(!file.exists()) {
//                 file = new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator + "properties.txt");//TODO remove legacy
//             }
//             if(file.exists()) {
//                 try {
//                     FileInputStream stream = new FileInputStream(file);
//                     BufferedReader br = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
//                     List<String> textList = new ArrayList<String>();
//                     String line = br.readLine();
//                     while(line != null) {
//                         textList.add(line);
//                         line = br.readLine();
//                     }
//                     br.close();
// 
//                     if(textList != null) {
//                         for(String s : textList) {
//                             String[] entry = s.split("=");
//                             if(entry[0].equals("optional")) {
//                                 if(Boolean.parseBoolean(entry[1])) return true;
//                             }
//                         }
//                     }
//                 } catch(Exception e) {
//                     e.printStackTrace();
//                 }
//             }
//             String version = installedMods.get(Constants.MOD_ID);
//             if(version.equals("${version}")) return true;
//             return version != null && version.equals(Constants.fullVersionString());
//         } else {
//             return true;
//         }
// 
//     }
// 
//     @EventHandler
//     public void preInit(FMLPreInitializationEvent event){
//         event.getModMetadata().version = Constants.fullVersionString();
//         proxy.preInit(event);
//         NetworkHandler.init();
//     }
// 
//     @EventHandler
//     public void init(FMLInitializationEvent event){
// 
//     }
// 
//     @EventHandler
//     public void postInit(FMLPostInitializationEvent event){
//         proxy.postInit();
//     }
// 
//     @EventHandler
//     public void processIMCRequests(FMLInterModComms.IMCEvent event){
//         proxy.processIMC(event);
//     }
// }


// Path: src/igwmod/network/AbstractPacket.java
import igwmod.IGWMod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.relauncher.Side;

package igwmod.network;


/**
 * 
 * @author MineMaarten
 */
public abstract class AbstractPacket<REQ extends IMessage> implements IMessage, IMessageHandler<REQ, REQ>{

    @Override
    public REQ onMessage(REQ message, MessageContext ctx){

        if(ctx.side == Side.SERVER) {
            handleServerSide(message, ctx.getServerHandler().player);
        } else {
            handleClientSide(message, IGWMod.proxy.getPlayer());