// Path: src/igwmod/lib/Constants.java
// public class Constants{
//     public static final String MOD_ID = "igwmod";
//     private static final String MASSIVE = "@MASSIVE@";
//     private static final String MAJOR = "@MAJOR@";
//     private static final String MINOR = "@MINOR@";
//     private static final String BUILD = "@BUILD_NUMBER@";
//     private static final String MC_VERSION = "@MC_VERSION@";
//     //  public static final String WIKI_PAGE_LOCATION = "https://github.com/MineMaarten/IGW-mod/archive/master.zip";// "http://www.minemaarten.com/wp-content/uploads/2013/12/WikiPages.zip";
//     //  public static final String ZIP_NAME = "igw";
//     //   public static final int CONNECTION_TIMEOUT = 3000;
//     //    public static final int READ_TIMEOUT = 5000;
//     //  public static final String INTERNET_UPDATE_CONFIG_KEY = "Update pages via internet";
//     //  public static final String USE_OFFLINE_WIKIPAGES_KEY = "Use offline wikipages";
//     public static final int DEFAULT_KEYBIND_OPEN_GUI = Keyboard.KEY_I;
// 
//     public static final int TEXTURE_MAP_ID = 15595;
// 
//     public static String fullVersionString(){
// 
//         return String.format("%s-%s.%s.%s-%s", MC_VERSION, MASSIVE, MAJOR, MINOR, BUILD);
//     }
// }
// 
// Path: src/igwmod/network/NetworkHandler.java
// public class NetworkHandler{
// 
//     public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Constants.MOD_ID);
//     private static int discriminant;
// 
//     /*
//      * The integer is the ID of the message, the Side is the side this message will be handled (received) on!
//      */
//     public static void init(){
// 
//         INSTANCE.registerMessage(MessageSendServerTab.class, MessageSendServerTab.class, discriminant++, Side.CLIENT);
//         INSTANCE.registerMessage(MessageMultiHeader.class, MessageMultiHeader.class, discriminant++, Side.CLIENT);
//         INSTANCE.registerMessage(MessageMultiPart.class, MessageMultiPart.class, discriminant++, Side.CLIENT);
//     }
// 
//     /*
//      * public static void INSTANCE.registerMessage(Class<? extends AbstractPacket<? extends IMessage>> clazz){ INSTANCE.registerMessage(clazz, clazz,
//      * discriminant++, Side.SERVER, discriminant++, Side.SERVER); }
//      */
// 
//     public static void sendToAll(IMessage message){
// 
//         INSTANCE.sendToAll(message);
//     }
// 
//     public static void sendTo(IMessage message, EntityPlayerMP player){
//         List<IMessage> messages = getSplitMessages(message);
//         for(IMessage m : messages) {
//             INSTANCE.sendTo(m, player);
//         }
//     }
// 
//     @SuppressWarnings("rawtypes")
//     public static void sendToAllAround(LocationIntPacket message, World world, double distance){
// 
//         sendToAllAround(message, message.getTargetPoint(world, distance));
//     }
// 
//     @SuppressWarnings("rawtypes")
//     public static void sendToAllAround(LocationIntPacket message, World world){
// 
//         sendToAllAround(message, message.getTargetPoint(world));
//     }
// 
//     @SuppressWarnings("rawtypes")
//     public static void sendToAllAround(LocationDoublePacket message, World world){
// 
//         sendToAllAround(message, message.getTargetPoint(world));
//     }
// 
//     public static void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point){
// 
//         INSTANCE.sendToAllAround(message, point);
//     }
// 
//     public static void sendToDimension(IMessage message, int dimensionId){
// 
//         INSTANCE.sendToDimension(message, dimensionId);
//     }
// 
//     public static void sendToServer(IMessage message){
// 
//         INSTANCE.sendToServer(message);
//     }
// 
//     public static final int MAX_SIZE = 65530;
// 
//     private static List<IMessage> getSplitMessages(IMessage message){
//         List<IMessage> messages = new ArrayList<IMessage>();
//         ByteBuf buf = Unpooled.buffer();
//         message.toBytes(buf);
//         byte[] bytes = buf.array();
//         if(bytes.length < MAX_SIZE) {
//             messages.add(message);
//         } else {
//             messages.add(new MessageMultiHeader(bytes.length));
//             int offset = 0;
//             while(offset < bytes.length) {
//                 messages.add(new MessageMultiPart(Arrays.copyOfRange(bytes, offset, Math.min(offset + MAX_SIZE, bytes.length))));
//                 offset += MAX_SIZE;
//             }
//         }
//         return messages;
//     }
// }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import igwmod.lib.Constants;
import igwmod.network.NetworkHandler;
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.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkCheckHandler;
import net.minecraftforge.fml.relauncher.Side;
                    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){
// Path: src/igwmod/lib/Constants.java
// public class Constants{
//     public static final String MOD_ID = "igwmod";
//     private static final String MASSIVE = "@MASSIVE@";
//     private static final String MAJOR = "@MAJOR@";
//     private static final String MINOR = "@MINOR@";
//     private static final String BUILD = "@BUILD_NUMBER@";
//     private static final String MC_VERSION = "@MC_VERSION@";
//     //  public static final String WIKI_PAGE_LOCATION = "https://github.com/MineMaarten/IGW-mod/archive/master.zip";// "http://www.minemaarten.com/wp-content/uploads/2013/12/WikiPages.zip";
//     //  public static final String ZIP_NAME = "igw";
//     //   public static final int CONNECTION_TIMEOUT = 3000;
//     //    public static final int READ_TIMEOUT = 5000;
//     //  public static final String INTERNET_UPDATE_CONFIG_KEY = "Update pages via internet";
//     //  public static final String USE_OFFLINE_WIKIPAGES_KEY = "Use offline wikipages";
//     public static final int DEFAULT_KEYBIND_OPEN_GUI = Keyboard.KEY_I;
// 
//     public static final int TEXTURE_MAP_ID = 15595;
// 
//     public static String fullVersionString(){
// 
//         return String.format("%s-%s.%s.%s-%s", MC_VERSION, MASSIVE, MAJOR, MINOR, BUILD);
//     }
// }
// 
// Path: src/igwmod/network/NetworkHandler.java
// public class NetworkHandler{
// 
//     public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Constants.MOD_ID);
//     private static int discriminant;
// 
//     /*
//      * The integer is the ID of the message, the Side is the side this message will be handled (received) on!
//      */
//     public static void init(){
// 
//         INSTANCE.registerMessage(MessageSendServerTab.class, MessageSendServerTab.class, discriminant++, Side.CLIENT);
//         INSTANCE.registerMessage(MessageMultiHeader.class, MessageMultiHeader.class, discriminant++, Side.CLIENT);
//         INSTANCE.registerMessage(MessageMultiPart.class, MessageMultiPart.class, discriminant++, Side.CLIENT);
//     }
// 
//     /*
//      * public static void INSTANCE.registerMessage(Class<? extends AbstractPacket<? extends IMessage>> clazz){ INSTANCE.registerMessage(clazz, clazz,
//      * discriminant++, Side.SERVER, discriminant++, Side.SERVER); }
//      */
// 
//     public static void sendToAll(IMessage message){
// 
//         INSTANCE.sendToAll(message);
//     }
// 
//     public static void sendTo(IMessage message, EntityPlayerMP player){
//         List<IMessage> messages = getSplitMessages(message);
//         for(IMessage m : messages) {
//             INSTANCE.sendTo(m, player);
//         }
//     }
// 
//     @SuppressWarnings("rawtypes")
//     public static void sendToAllAround(LocationIntPacket message, World world, double distance){
// 
//         sendToAllAround(message, message.getTargetPoint(world, distance));
//     }
// 
//     @SuppressWarnings("rawtypes")
//     public static void sendToAllAround(LocationIntPacket message, World world){
// 
//         sendToAllAround(message, message.getTargetPoint(world));
//     }
// 
//     @SuppressWarnings("rawtypes")
//     public static void sendToAllAround(LocationDoublePacket message, World world){
// 
//         sendToAllAround(message, message.getTargetPoint(world));
//     }
// 
//     public static void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point){
// 
//         INSTANCE.sendToAllAround(message, point);
//     }
// 
//     public static void sendToDimension(IMessage message, int dimensionId){
// 
//         INSTANCE.sendToDimension(message, dimensionId);
//     }
// 
//     public static void sendToServer(IMessage message){
// 
//         INSTANCE.sendToServer(message);
//     }
// 
//     public static final int MAX_SIZE = 65530;
// 
//     private static List<IMessage> getSplitMessages(IMessage message){
//         List<IMessage> messages = new ArrayList<IMessage>();
//         ByteBuf buf = Unpooled.buffer();
//         message.toBytes(buf);
//         byte[] bytes = buf.array();
//         if(bytes.length < MAX_SIZE) {
//             messages.add(message);
//         } else {
//             messages.add(new MessageMultiHeader(bytes.length));
//             int offset = 0;
//             while(offset < bytes.length) {
//                 messages.add(new MessageMultiPart(Arrays.copyOfRange(bytes, offset, Math.min(offset + MAX_SIZE, bytes.length))));
//                 offset += MAX_SIZE;
//             }
//         }
//         return messages;
//     }
// }


// Path: src/igwmod/IGWMod.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import igwmod.lib.Constants;
import igwmod.network.NetworkHandler;
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.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkCheckHandler;
import net.minecraftforge.fml.relauncher.Side;

                    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();