Beispiel #1
0
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            int   index = modlist.SelectedIndex;
            Mcmod mod   = showDone.Checked ? _mods[index] : _nonFinishedMods[index];

            mod.IsSkipping = skipmod.Checked;
        }
Beispiel #2
0
        private void textBoxModID_TextChanged(object sender, EventArgs e)
        {
            int   index = modlist.SelectedIndex;
            Mcmod mod   = showDone.Checked ? _mods[index] : _nonFinishedMods[index];

            mod.Modid         = !String.IsNullOrWhiteSpace(textBoxModID.Text) ? textBoxModID.Text : String.Empty;
            mod.FromUserInput = true;
        }
        private void CreateTechnicPermissionInfo(Mcmod mod, PermissionPolicy pl, string customPermissionText, string modlink)
        {
            string ps = string.Format("{0}({1}) by {2}{3}At {4}{3}Permissions are {5}{3}", mod.Name, mod.Modid, GetAuthors(mod), Environment.NewLine, modlink, pl);

            if (!string.IsNullOrWhiteSpace(customPermissionText))
            {
                ps += customPermissionText + Environment.NewLine;
            }
            File.AppendAllText(_technicPermissionList, ps + Environment.NewLine);
        }
        public void CreateTechnicModZip(Mcmod mod, string modfile)
        {
            if (mod.IsSkipping)
            {
                return;
            }
            string fileName = modfile.Substring(modfile.LastIndexOf(Globalfunctions.PathSeperator) + 1);
            string modMd5   = SqlHelper.CalculateMd5(modfile);

            _modsSqLhelper.AddMod(mod.Name, mod.Modid, mod.Version, mod.Mcversion, fileName, modMd5, false);
            # region permissions
            if (TechnicPermissions.Checked)
        private void CreateTechnicPermissionInfo(Mcmod mod, PermissionPolicy pl, string customPermissionText = null)
        {
            string modlink = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;

            while (string.IsNullOrWhiteSpace(modlink) || !Uri.IsWellFormedUriString(modlink, UriKind.Absolute))
            {
                modlink = Prompt.ShowDialog("What is the link to " + mod.Name + "?", "Mod link", false, Prompt.ModsLeftString(_totalMods, _currentMod));
                if (!Uri.IsWellFormedUriString(modlink, UriKind.Absolute))
                {
                    MessageBox.Show("Not a proper url");
                }
            }
            CreateTechnicPermissionInfo(mod, pl, customPermissionText, modlink);
        }
Beispiel #6
0
 private static Boolean IsFullyInformed(Mcmod mod)
 {
     if (String.IsNullOrWhiteSpace(mod.Name) || String.IsNullOrWhiteSpace(mod.Version) ||
         String.IsNullOrWhiteSpace(mod.Mcversion) || String.IsNullOrWhiteSpace(mod.Modid) || (mod.AuthorList == null && mod.Authors == null))
     {
         return(false);
     }
     Debug.WriteLine(mod.Version);
     if (mod.Name.Contains("${") || mod.Version.Contains("${") || mod.Mcversion.Contains("${") || mod.Modid.Contains("${") || mod.Version.ToLower().Contains("@version@") || mod.Modid.ToLower().Contains("example") || mod.Version.ToLower().Contains("example") || mod.Name.ToLower().Contains("example"))
     {
         return(false);
     }
     return(true);
 }
Beispiel #7
0
        public static Mcmod ReikasMods(String fileName)
        {
            Mcmod mod = new Mcmod();

            fileName = fileName.Remove(fileName.LastIndexOf(".", StringComparison.Ordinal));

            //Figure out mod name
            String[] reikas = fileName.Split(' ');

            mod.Name      = reikas[0].Replace(" ", String.Empty);
            mod.Mcversion = reikas[1].Replace(" ", String.Empty);
            mod.Version   = reikas[2].Replace(" ", String.Empty);

            return(mod);
        }
Beispiel #8
0
        public static Mcmod GoodVersioning(String fileName)
        {
            fileName = fileName.Remove(fileName.LastIndexOf("."));
            Mcmod mod = new Mcmod();

            //Figure out modname
            String modname = "";

            foreach (char c in fileName)
            {
                if (!(c.Equals('-')))
                {
                    modname = modname + c;
                }
                else
                {
                    break;
                }
            }
            mod.Name = modname;
            fileName = fileName.Replace(modname + "-", "");

            //Figure out minecraft version
            String mcversion = "";

            foreach (char c in fileName)
            {
                if (!(c.Equals('-')))
                {
                    mcversion = mcversion + c;
                }
                else
                {
                    break;
                }
            }
            mod.Mcversion = mcversion;

            //Figure out modversion
            fileName    = fileName.Replace(mcversion + "-", "");
            mod.Version = fileName;


            return(mod);
        }
Beispiel #9
0
        public static Mcmod WailaPattern(String fileName) // waila-1.5.5_1.7.10.jar
        {
            fileName = fileName.Remove(fileName.LastIndexOf(".", StringComparison.Ordinal));
            Mcmod mod = new Mcmod();

            String name = "";

            foreach (char c in fileName)
            {
                if (!(c.Equals('-')))
                {
                    name = name + c;
                }
                else
                {
                    break;
                }
            }
            mod.Name = name;

            fileName = fileName.Replace(name, "");

            String version = "";

            foreach (char c in fileName)
            {
                if (!(c.Equals('_')))
                {
                    version = version + c;
                }
                else
                {
                    break;
                }
            }
            mod.Version = version;

            fileName      = fileName.Replace("_", "").Replace(version, "");
            mod.Mcversion = fileName;

            return(mod);
        }
Beispiel #10
0
        private void textBoxAuthor_TextChanged(object sender, EventArgs e)
        {
            int   index = modlist.SelectedIndex;
            Mcmod mod   = showDone.Checked ? _mods[index] : _nonFinishedMods[index];

            if (String.IsNullOrWhiteSpace(textBoxAuthor.Text))
            {
                mod.Authors = null;
            }
            else
            {
                String        a = textBoxAuthor.Text;
                List <String> s = a.Replace(" ", "").Split(',').ToList();
                mod.Authors = s;
                if (!String.IsNullOrWhiteSpace(textBoxModID.Text))
                {
                    OwnPermissionsSqlHelper ownPermissionsSqlHelper = new OwnPermissionsSqlHelper();
                    ownPermissionsSqlHelper.AddAuthor(textBoxModID.Text, a);
                }
            }
            mod.FromUserInput = true;
        }
Beispiel #11
0
        private Boolean AreModDone(Mcmod mod)
        {
            if (!IsFullyInformed(mod))
            {
                return(false);
            }
            OwnPermissionsSqlHelper ownPermissionsSqlHelper = new OwnPermissionsSqlHelper();
            bool b = ownPermissionsSqlHelper.DoUserHavePermission(mod.Modid).HasPermission;

            if (b)
            {
                return(true);
            }
            if (_solderHelper.CreateTechnicPack.Checked && _solderHelper.TechnicPermissions.Checked)
            {
                if (_ftbPermissionsSqlHelper.FindPermissionPolicy(mod.Modid,
                                                                  _solderHelper.TechnicPublicPermissions.Checked) != PermissionPolicy.Open)
                {
                    return(false);
                }
            }
            if (!_solderHelper.CreateFTBPack.Checked)
            {
                return(true);
            }
            PermissionPolicy p = _ftbPermissionsSqlHelper.FindPermissionPolicy(mod.Modid,
                                                                               _solderHelper.PublicFTBPack.Checked);

            if (p == PermissionPolicy.Open || p == PermissionPolicy.FTB)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #12
0
        private void modlist_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = modlist.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            Mcmod m = showDone.Checked ? _mods[index] : _nonFinishedMods[index];

            skipmod.Checked      = m.IsSkipping;
            textBoxFileName.Text = m.Filename;
            textBoxAuthor.Text   = m.Authors != null?_solderHelper.GetAuthors(m) : String.Empty;

            textBoxModName.Text = m.Name ?? String.Empty;

            textBoxModID.Text = m.Modid ?? String.Empty;
            //_updatingModID = String.IsNullOrWhiteSpace(textBoxModID.Text);
            //textBoxModID.ReadOnly = !String.IsNullOrWhiteSpace(textBoxModID.Text);

            textBoxModVersion.Text = m.Version ?? String.Empty;

            ShowPermissions();
        }
Beispiel #13
0
        public Modinfo(List <Mcmod> modsList, SolderHelper solderHelper)
        {
            _nonFinishedMods = new List <Mcmod>();
            _solderHelper    = solderHelper;
            var tmp = from mcmod1 in modsList
                      where mcmod1.Name != null
                      orderby mcmod1.Name
                      select mcmod1;

            _mods = new List <Mcmod>();
            _mods.AddRange(tmp.ToList());
            tmp = from mcmod1 in modsList
                  where mcmod1.Name == null
                  orderby mcmod1.Filename
                  select mcmod1;

            _mods.AddRange(tmp.ToList());
            InitializeComponent();
            foreach (Mcmod mcmod in _mods)
            {
                if (String.IsNullOrWhiteSpace(mcmod.Mcversion))
                {
                    mcmod.Mcversion = solderHelper._currentMcVersion;
                }
                mcmod.Aredone = AreModDone(mcmod);
                if (!mcmod.Aredone)
                {
                    ModListSqlHelper modListSqlHelper = new ModListSqlHelper();
                    Mcmod            m = modListSqlHelper.GetModInfo(SqlHelper.CalculateMd5(mcmod.Path));
                    if (m == null)
                    {
                        if (mcmod.Authors == null || mcmod.AuthorList == null)
                        {
                            String a = _solderHelper.GetAuthors(mcmod, true);
                            if (!String.IsNullOrWhiteSpace(a))
                            {
                                List <String> s = a.Replace(" ", "").Split(',').ToList();
                                mcmod.Authors = s;
                            }
                        }
                        if (!IsValid(mcmod.Mcversion))
                        {
                            mcmod.Mcversion = _solderHelper._currentMcVersion;
                        }
                        if (AreModDone(mcmod))
                        {
                            mcmod.Aredone = true;
                        }
                        else
                        {
                            DataSuggest ds = new DataSuggest();
                            m = ds.GetMcmod(SqlHelper.CalculateMd5(mcmod.Path));
                            if (m != null)
                            {
                                if (!IsValid(mcmod.Name))
                                {
                                    mcmod.Name = m.Name;
                                }
                                if (!IsValid(mcmod.Modid))
                                {
                                    mcmod.Modid = m.Modid;
                                }
                                if (!IsValid(mcmod.Version))
                                {
                                    mcmod.Version = m.Version;
                                }
                                mcmod.FromSuggestion = true;
                            }
                            if (AreModDone(mcmod))
                            {
                                mcmod.Aredone = true;
                            }
                            else
                            {
                                _nonFinishedMods.Add(mcmod);
                                modlist.Items.Add(String.IsNullOrWhiteSpace(mcmod.Name) ? mcmod.Filename : mcmod.Name);
                            }
                        }
                    }
                    if (!mcmod.Aredone)
                    {
                        if (m != null)
                        {
                            if (!IsValid(mcmod.Name) &&
                                !String.IsNullOrWhiteSpace(m.Name))
                            {
                                mcmod.Name = m.Name;
                            }
                            if (!IsValid(mcmod.Modid) && !String.IsNullOrWhiteSpace(m.Modid))
                            {
                                mcmod.Modid = m.Modid;
                            }
                            if (!IsValid(mcmod.Version) && !String.IsNullOrWhiteSpace(m.Version))
                            {
                                mcmod.Version = m.Version;
                            }
                        }
                        if (!IsValid(mcmod.Mcversion))
                        {
                            mcmod.Mcversion = _solderHelper._currentMcVersion;
                        }
                        if (mcmod.Authors == null || mcmod.AuthorList == null)
                        {
                            String a = _solderHelper.GetAuthors(mcmod, true);
                            if (a != null)
                            {
                                List <String> s = a.Replace(" ", "").Split(',').ToList();
                                mcmod.Authors = s;
                            }
                        }
                        if (AreModDone(mcmod))
                        {
                            mcmod.Aredone = true;
                        }
                        else
                        {
                            DataSuggest ds = new DataSuggest();
                            m = ds.GetMcmod(SqlHelper.CalculateMd5(mcmod.Path));
                            if (m != null)
                            {
                                if (!IsValid(mcmod.Name))
                                {
                                    mcmod.Name = m.Name;
                                }
                                if (!IsValid(mcmod.Modid))
                                {
                                    mcmod.Modid = m.Modid;
                                }
                                if (!IsValid(mcmod.Version))
                                {
                                    mcmod.Version = m.Version;
                                }
                                mcmod.FromSuggestion = true;
                            }
                            if (AreModDone(mcmod))
                            {
                                mcmod.Aredone = true;
                            }
                            else
                            {
                                if (!_nonFinishedMods.Contains(mcmod))
                                {
                                    _nonFinishedMods.Add(mcmod);
                                    modlist.Items.Add(String.IsNullOrWhiteSpace(mcmod.Name) ? mcmod.Filename : mcmod.Name);
                                }
                            }
                        }
                    }
                }
            }
            if (modlist.Items.Count <= 0)
            {
            }
            else
            {
                modlist.SelectedIndex = 0;
            }
        }
        public void CreateFtbPackZip(Mcmod mod, string modfile)
        {
            if (mod.IsSkipping)
            {
                return;
            }
            string fileName = modfile.Substring(modfile.LastIndexOf(Globalfunctions.PathSeperator) + 1);
            if (IsWierdMod(fileName) == 0)
            {
                return;
            }
            string modMd5 = SqlHelper.CalculateMd5(modfile);
            if (!mod.IsIgnore)
            {
                if (!mod.UseShortName)
                {
                    _modsSqLhelper.AddMod(mod.Name, mod.Modid, mod.Version, mod.Mcversion, fileName, modMd5, false);
                }
                if (true)
                {
                    #region Permissions checking
                    PermissionPolicy permLevel = _ftbPermsSqLhelper.FindPermissionPolicy(mod.Modid, PublicFTBPack.Checked);

                    string overwritelink;
                    OwnPermissions ownPermissions;
                    switch (permLevel)
                    {
                        case PermissionPolicy.Open:
                            break;
                        case PermissionPolicy.Notify:
                            ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                            if (!ownPermissions.HasPermission)
                            {
                                overwritelink = Prompt.ShowDialog(string.Format("{0} requires that you notify the author of inclusion.{1}Please provide proof(an imgur link) that you have done this:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name).Replace(" ", "");
                                while (true)
                                {
                                    if (overwritelink.ToLower().Equals("skip".ToLower()))
                                    {
                                        mod.IsSkipping = true;
                                        return;
                                    }
                                    if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                    {
                                        if (overwritelink.ToLower().Contains("imgur"))
                                        {
                                            _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink);
                                            //Get Author
                                            string a = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
                                            CreateFtbPermissionInfo(mod.Name, mod.Modid, a, overwritelink);
                                            break;
                                        }
                                        MessageBox.Show("Not an imgur link");
                                    }
                                    else
                                    {
                                        MessageBox.Show("Invalid url");
                                    }
                                    overwritelink = Prompt.ShowDialog(string.Format("{0} requires that you notify the author of inclusion.{1}Please provide proof(an imgur link) that you have done this:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                                }
                            }
                            else
                            {
                                //Get Author
                                string a = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
                                CreateFtbPermissionInfo(mod.Name, mod.Modid, a, ownPermissions.PermissionLink);
                            }
                            break;
                        case PermissionPolicy.FTB:
                            break;
                        case PermissionPolicy.Request:
                            ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                            if (!ownPermissions.HasPermission)
                            {
                                overwritelink = Prompt.ShowDialog(string.Format("This mod requires that you request permissions from the Mod Author of {0}{1}Please provide proof(an imgur link) that you have this permission:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                                while (true)
                                {
                                    if (overwritelink.ToLower().Equals("skip".ToLower()))
                                    {
                                        mod.IsSkipping = true;
                                        return;
                                    }
                                    if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                    {
                                        if (overwritelink.ToLower().Contains("imgur"))
                                        {
                                            _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink);
                                            //Get Author
                                            string a = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
                                            CreateFtbPermissionInfo(mod.Name, mod.Modid, a, overwritelink);
                                            break;
                                        }
                                        MessageBox.Show("Not an imgur link");
                                    }
                                    else
                                    {
                                        MessageBox.Show("Invalid url");
                                    }
                                    overwritelink = Prompt.ShowDialog(string.Format("This mod requires that you request permissions from the Mod Author of {0}{1}Please provide proof(an imgur link) that you have this permission:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                                }
                            }
                            else
                            {
                                //Get Author
                                string a = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
                                CreateFtbPermissionInfo(mod.Name, mod.Modid, a, ownPermissions.PermissionLink);
                            }
                            break;
                        case PermissionPolicy.Closed:
                            ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                            if (!ownPermissions.HasPermission)
                            {
                                overwritelink = Prompt.ShowDialog(string.Format("The FTB permissionsheet states that permissions for {0} is closed.{1}Please provide proof(an imgur link) that this is not the case:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                                while (true)
                                {
                                    if (overwritelink.ToLower().Equals("skip".ToLower()))
                                    {
                                        mod.IsSkipping = true;
                                        return;
                                    }
                                    if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                    {
                                        if (overwritelink.ToLower().Contains("imgur"))
                                        {
                                            _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink);
                                            //Get Author
                                            string a = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
                                            CreateFtbPermissionInfo(mod.Name, mod.Modid, a, overwritelink);
                                            break;
                                        }
                                        MessageBox.Show("Not an imgur link");
                                    }
                                    else
                                    {
                                        MessageBox.Show("Invalid url");
                                    }
                                    overwritelink = Prompt.ShowDialog(string.Format("The FTB permissionsheet states that permissions for {0} is closed.{1}Please provide proof(an imgur link) that this is not the case:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                                }
                            }
                            else
                            {
                                //Get Author
                                string a = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
                                CreateFtbPermissionInfo(mod.Name, mod.Modid, a, ownPermissions.PermissionLink);
                            }
                            break;
                        case PermissionPolicy.Unknown:
                            ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                            if (!ownPermissions.HasPermission)
                            {
                                overwritelink = Prompt.ShowDialog(string.Format("Permissions for {0} is unknown{1}Please provide proof(an imgur link) of permissions:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                                while (true)
                                {
                                    if (overwritelink.ToLower().Equals("skip".ToLower()))
                                    {
                                        mod.IsSkipping = true;
                                        return;
                                    }
                                    if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                    {
                                        if (overwritelink.ToLower().Contains("imgur"))
                                        {
                                            break;
                                        }
                                        MessageBox.Show("Not an imgur link");
                                    }
                                    else
                                    {
                                        MessageBox.Show("Invalid url");
                                    }
                                    overwritelink = Prompt.ShowDialog(string.Format("Permissions for {0} is unknown{1}Please provide proof(an imgur link) of permissions:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                                }
                                string modLink;
                                while (true)
                                {
                                    modLink = Prompt.ShowDialog(string.Format("Please provide a link to {0}:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name).Replace(" ", "");
                                    if (modLink.ToLower().Equals("skip".ToLower()))
                                    {
                                        mod.IsSkipping = true;
                                        return;
                                    }
                                    if (Uri.IsWellFormedUriString(modLink, UriKind.Absolute))
                                    {
                                        _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink, modLink);
                                        break;

                                    }
                                    MessageBox.Show("Invalid url");

                                }
                                string a = GetAuthors(mod);
                                CreateOwnPermissionInfo(mod.Name, mod.Modid, a, overwritelink, modLink);

                            }
                            else
                            {
                                string a = GetAuthors(mod);
                                CreateOwnPermissionInfo(mod.Name, mod.Modid, a, ownPermissions.PermissionLink, ownPermissions.ModLink);
                            }
                            break;
                    }
                    #endregion
                }
            }

            if (string.IsNullOrWhiteSpace(_ftbModpackArchive))
            {
                while (string.IsNullOrWhiteSpace(_modpackName))
                {
                    _modpackName = Prompt.ShowDialog("What is the Modpack Name?", "Modpack Name");
                }
                while (string.IsNullOrWhiteSpace(_modpackVersion))
                {
                    _modpackVersion = Prompt.ShowDialog("What Version is the modpack?", "Modpack Version");
                }
                if (string.IsNullOrWhiteSpace(_modpackArchive))
                {
                    _modpackArchive = Path.Combine(_outputDirectory, string.Format("{0}-{1}.zip", _modpackName, _modpackVersion));
                    _ftbModpackArchive = Path.Combine(_outputDirectory, _modpackName + "-" + _modpackVersion + "-FTB" + ".zip");
                }

            }

            string tempModDirectory = Path.Combine(_outputDirectory, "minecraft", "mods");
            Directory.CreateDirectory(tempModDirectory);
            string tempFile = Path.Combine(tempModDirectory, fileName);
            int index = tempFile.LastIndexOf(Globalfunctions.PathSeperator);
            string tempFileDirectory = tempFile.Remove(index);
            Directory.CreateDirectory(tempFileDirectory);
            File.Copy(modfile, tempFile, true);

            if (Globalfunctions.IsUnix())
            {
                Environment.CurrentDirectory = _outputDirectory;
                _startInfo.FileName = "zip";
                _startInfo.Arguments = string.Format("-r \"{0}\" \"{1}\"", _ftbModpackArchive, "minecraft");
            }
            else
            {
                Environment.CurrentDirectory = _outputDirectory;
                _startInfo.Arguments = string.Format("a -y \"{0}\" \"{1}\"", _ftbModpackArchive, "minecraft");
            }

            _process.StartInfo = _startInfo;
            _process.Start();
            _process.WaitForExit();
            Directory.Delete(tempModDirectory, true);

            if (mod.HasBeenWritenToModlist)
                return;
            File.AppendAllText(_modlistTextFile, mod.Name + Environment.NewLine);
            mod.HasBeenWritenToModlist = true;
        }
        public void CreateFtbPackZip(Mcmod mod, string modfile)
        {
            if (mod.IsSkipping)
            {
                return;
            }
            string fileName = modfile.Substring(modfile.LastIndexOf(Globalfunctions.PathSeperator) + 1);

            if (IsWierdMod(fileName) == 0)
            {
                return;
            }
            string modMd5 = SqlHelper.CalculateMd5(modfile);

            if (!mod.IsIgnore)
            {
                if (!mod.UseShortName)
                {
                    _modsSqLhelper.AddMod(mod.Name, mod.Modid, mod.Version, mod.Mcversion, fileName, modMd5, false);
                }
                if (true)
                {
                    #region Permissions checking
                    PermissionPolicy permLevel = _ftbPermsSqLhelper.FindPermissionPolicy(mod.Modid, PublicFTBPack.Checked);

                    string         overwritelink;
                    OwnPermissions ownPermissions;
                    switch (permLevel)
                    {
                    case PermissionPolicy.Open:
                        break;

                    case PermissionPolicy.Notify:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog(string.Format("{0} requires that you notify the author of inclusion.{1}Please provide proof(an imgur link) that you have done this:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name).Replace(" ", "");
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink);
                                        //Get Author
                                        string a = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
                                        CreateFtbPermissionInfo(mod.Name, mod.Modid, a, overwritelink);
                                        break;
                                    }
                                    MessageBox.Show("Not an imgur link");
                                }
                                else
                                {
                                    MessageBox.Show("Invalid url");
                                }
                                overwritelink = Prompt.ShowDialog(string.Format("{0} requires that you notify the author of inclusion.{1}Please provide proof(an imgur link) that you have done this:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                            }
                        }
                        else
                        {
                            //Get Author
                            string a = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
                            CreateFtbPermissionInfo(mod.Name, mod.Modid, a, ownPermissions.PermissionLink);
                        }
                        break;

                    case PermissionPolicy.FTB:
                        break;

                    case PermissionPolicy.Request:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog(string.Format("This mod requires that you request permissions from the Mod Author of {0}{1}Please provide proof(an imgur link) that you have this permission:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink);
                                        //Get Author
                                        string a = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
                                        CreateFtbPermissionInfo(mod.Name, mod.Modid, a, overwritelink);
                                        break;
                                    }
                                    MessageBox.Show("Not an imgur link");
                                }
                                else
                                {
                                    MessageBox.Show("Invalid url");
                                }
                                overwritelink = Prompt.ShowDialog(string.Format("This mod requires that you request permissions from the Mod Author of {0}{1}Please provide proof(an imgur link) that you have this permission:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                            }
                        }
                        else
                        {
                            //Get Author
                            string a = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
                            CreateFtbPermissionInfo(mod.Name, mod.Modid, a, ownPermissions.PermissionLink);
                        }
                        break;

                    case PermissionPolicy.Closed:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog(string.Format("The FTB permissionsheet states that permissions for {0} is closed.{1}Please provide proof(an imgur link) that this is not the case:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink);
                                        //Get Author
                                        string a = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
                                        CreateFtbPermissionInfo(mod.Name, mod.Modid, a, overwritelink);
                                        break;
                                    }
                                    MessageBox.Show("Not an imgur link");
                                }
                                else
                                {
                                    MessageBox.Show("Invalid url");
                                }
                                overwritelink = Prompt.ShowDialog(string.Format("The FTB permissionsheet states that permissions for {0} is closed.{1}Please provide proof(an imgur link) that this is not the case:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                            }
                        }
                        else
                        {
                            //Get Author
                            string a = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
                            CreateFtbPermissionInfo(mod.Name, mod.Modid, a, ownPermissions.PermissionLink);
                        }
                        break;

                    case PermissionPolicy.Unknown:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog(string.Format("Permissions for {0} is unknown{1}Please provide proof(an imgur link) of permissions:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        break;
                                    }
                                    MessageBox.Show("Not an imgur link");
                                }
                                else
                                {
                                    MessageBox.Show("Invalid url");
                                }
                                overwritelink = Prompt.ShowDialog(string.Format("Permissions for {0} is unknown{1}Please provide proof(an imgur link) of permissions:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod)).Replace(" ", "");
                            }
                            string modLink;
                            while (true)
                            {
                                modLink = Prompt.ShowDialog(string.Format("Please provide a link to {0}:{1}Enter \"skip\" to skip the mod.", mod.Name, Environment.NewLine), mod.Name).Replace(" ", "");
                                if (modLink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(modLink, UriKind.Absolute))
                                {
                                    _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink, modLink);
                                    break;
                                }
                                MessageBox.Show("Invalid url");
                            }
                            string a = GetAuthors(mod);
                            CreateOwnPermissionInfo(mod.Name, mod.Modid, a, overwritelink, modLink);
                        }
                        else
                        {
                            string a = GetAuthors(mod);
                            CreateOwnPermissionInfo(mod.Name, mod.Modid, a, ownPermissions.PermissionLink, ownPermissions.ModLink);
                        }
                        break;
                    }
                    #endregion
                }
            }

            if (string.IsNullOrWhiteSpace(_ftbModpackArchive))
            {
                while (string.IsNullOrWhiteSpace(_modpackName))
                {
                    _modpackName = Prompt.ShowDialog("What is the Modpack Name?", "Modpack Name");
                }
                while (string.IsNullOrWhiteSpace(_modpackVersion))
                {
                    _modpackVersion = Prompt.ShowDialog("What Version is the modpack?", "Modpack Version");
                }
                if (string.IsNullOrWhiteSpace(_modpackArchive))
                {
                    _modpackArchive    = Path.Combine(_outputDirectory, string.Format("{0}-{1}.zip", _modpackName, _modpackVersion));
                    _ftbModpackArchive = Path.Combine(_outputDirectory, _modpackName + "-" + _modpackVersion + "-FTB" + ".zip");
                }
            }


            string tempModDirectory = Path.Combine(_outputDirectory, "minecraft", "mods");
            Directory.CreateDirectory(tempModDirectory);
            string tempFile          = Path.Combine(tempModDirectory, fileName);
            int    index             = tempFile.LastIndexOf(Globalfunctions.PathSeperator);
            string tempFileDirectory = tempFile.Remove(index);
            Directory.CreateDirectory(tempFileDirectory);
            File.Copy(modfile, tempFile, true);

            if (Globalfunctions.IsUnix())
            {
                Environment.CurrentDirectory = _outputDirectory;
                _startInfo.FileName          = "zip";
                _startInfo.Arguments         = string.Format("-r \"{0}\" \"{1}\"", _ftbModpackArchive, "minecraft");
            }
            else
            {
                Environment.CurrentDirectory = _outputDirectory;
                _startInfo.Arguments         = string.Format("a -y \"{0}\" \"{1}\"", _ftbModpackArchive, "minecraft");
            }

            _process.StartInfo = _startInfo;
            _process.Start();
            _process.WaitForExit();
            Directory.Delete(tempModDirectory, true);

            if (mod.HasBeenWritenToModlist)
            {
                return;
            }
            File.AppendAllText(_modlistTextFile, mod.Name + Environment.NewLine);
            mod.HasBeenWritenToModlist = true;
        }
        public string GetAuthors(Mcmod mod, Boolean listview = false)
        {
            string authorString = "";
            bool isFirst = true;
            if (mod.Authors != null && mod.Authors.Count != 0)
            {
                foreach (string author in mod.Authors)
                {
                    if (isFirst)
                    {
                        authorString = author;
                        isFirst = false;
                    }
                    else
                    {
                        authorString += ", " + author;
                    }
                }
            }
            else
            {
                if (mod.AuthorList != null && mod.AuthorList.Count != 0)
                {
                    foreach (string author in mod.AuthorList)
                    {
                        if (isFirst)
                        {
                            authorString = author;
                            isFirst = false;
                        }
                        else
                        {
                            authorString += ", " + author;
                        }
                    }
                }
                else
                {
                    if (String.IsNullOrWhiteSpace(mod.Modid))
                    {
                        return "";
                    }

                    Permission temp = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid);

                    if (temp == null)
                    {
                        authorString = "";
                    }
                    else
                    {
                        authorString = temp.modAuthors;
                    }

                    if (String.IsNullOrWhiteSpace(authorString))
                    {
                        authorString = _ownPermsSqLhelper.GetAuthor(mod.Modid);
                        if (String.IsNullOrWhiteSpace(authorString))
                        {
                            if (listview)
                            {
                                return null;
                            }
                            authorString = Prompt.ShowDialog("Who is the author of " + mod.Name + "?" + Environment.NewLine + "If you leave this empty the author list in the output will also be empty.", "Mod Author", false, Prompt.ModsLeftString(_totalMods, _currentMod));

                        }
                    }
                }
            }
            _ownPermsSqLhelper.AddAuthor(mod.Modid, authorString);
            return authorString;
        }
        private void RequireUserInfo(Mcmod currentData, String file)
        {
            try
            {
                Mcmod mod;
                String s = SqlHelper.CalculateMd5(file);
                Debug.WriteLine(s);
                DataSuggest suggest = new DataSuggest();

                try
                {
                    mod = _modsSqLhelper.GetModInfo(s);
                    Debug.WriteLine("Got from local database");
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                    mod = suggest.GetMcmod(s);
                    if (mod == null)
                    {
                        mod = new Mcmod();
                    }
                    else
                    {
                        mod.FromSuggestion = true;
                        Debug.WriteLine("Got from remove database");
                    }
                }
                if (mod == null)
                {
                    Debug.WriteLine("didn't get anything from local database");
                    mod = suggest.GetMcmod(SqlHelper.CalculateMd5(file));
                    if (mod == null)
                    {
                        mod = new Mcmod();
                    }
                    else
                    {
                        mod.FromSuggestion = true;
                        Debug.WriteLine("Got from remove database");
                    }
                }

                String fileName = file.Substring(file.LastIndexOf(Globalfunctions.PathSeperator) + 1);
                fileName = fileName.Remove(fileName.LastIndexOf(".", StringComparison.Ordinal));

                if (currentData.Name != null && !currentData.Name.Contains("${") && !currentData.Name.ToLower().Contains("example"))
                {
                    mod.Name = currentData.Name;

                }
                else
                {
                    if (mod.Name == null && (String.IsNullOrWhiteSpace(currentData.Name) || currentData.Name.Contains("${") || currentData.Name.ToLower().Contains("example")))
                    {
                        String a =
                            string.Format("Mod name of {0}{1}Go bug the mod author to include an mcmod.info file!",
                                fileName, Environment.NewLine);
                        mod.Name = Prompt.ShowDialog(a, "Mod Name", false,
                            Prompt.ModsLeftString(_totalMods, _currentMod));
                        currentData.Name = mod.Name;
                        if (mod.Name.Equals(""))
                            return;
                        mod.FromUserInput = true;
                    }

                }
                if (currentData.Version != null && !currentData.Version.Contains("${") && !currentData.Version.ToLower().Contains("@version@") && !currentData.Version.ToLower().Contains("example"))
                    mod.Version = currentData.Version.Replace(" ", "-").ToLower();
                else
                {
                    if (mod.Version == null && (String.IsNullOrWhiteSpace(currentData.Version) || currentData.Version.Contains("${") || currentData.Version.ToLower().Contains("@version@") || currentData.Version.ToLower().Contains("example")))
                    {
                        String a =
                            String.Format(
                                "Mod version of {0}" + Environment.NewLine +
                                "Go bug the mod author to include an mcmod.info file!", fileName);
                        mod.Version = Prompt.ShowDialog(a, "Mod Version", false,
                            Prompt.ModsLeftString(_totalMods, _currentMod));
                        mod.Version = mod.Version.Replace(" ", "-").ToLower();
                        if (mod.Version.Equals(""))
                            return;
                        mod.FromUserInput = true;
                    }
                }
                if (mod.Version != null)
                {
                    mod.Version = mod.Version.Replace(" ", "-");
                }

                if (currentData.Mcversion != null && !currentData.Mcversion.Contains("${") && !currentData.Mcversion.ToLower().Contains("example"))
                    mod.Mcversion = currentData.Mcversion;
                else if (mod.Mcversion == null && (String.IsNullOrWhiteSpace(currentData.Mcversion) || currentData.Mcversion.Contains("${") || currentData.Mcversion.ToLower().Contains("example")))
                    if (_currentMcVersion == null)
                    {
                        Mcselector selector = new Mcselector(this);
                        selector.ShowDialog();
                        currentData.Mcversion = _currentMcVersion;
                    }
                    else
                    {
                        mod.Mcversion = _currentMcVersion;
                        currentData.Mcversion = _currentMcVersion;
                    }

                if (!String.IsNullOrWhiteSpace(currentData.Modid) && !currentData.Modid.ToLower().Contains("example") && !currentData.Modid.Contains("${"))
                {
                    mod.Modid = currentData.Modid;
                }
                //mod.Modid = currentData.Modid ?? mod.Name.Replace(" ", "").ToLower();
                if (mod.Name != null && (String.IsNullOrWhiteSpace(mod.Modid) || mod.Modid.Contains("${") || mod.Modid.ToLower().Contains("example")))
                {
                    mod.Modid = mod.Name.ToLower();
                }
                mod.Modid = mod.Name.Replace(" ", "");

                string md5 = SqlHelper.CalculateMd5(file);
                if (mod.FromUserInput && !mod.FromSuggestion && !suggest.IsModSuggested(md5))
                {
                    String a = GetAuthors(mod);
                    suggest.Suggest(fileName, mod.Mcversion, mod.Version, md5, mod.Modid, mod.Name, a);
                }

                if (CreateTechnicPack.Checked)
                    CreateTechnicModZip(mod, file);
                if (CreateFTBPack.Checked)
                    CreateFtbPackZip(mod, file);
            }
            catch (NullReferenceException ex)
            {
                String error = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "error.txt");
                File.AppendAllText(error, ex.Message);
                File.AppendAllText(error, ex.StackTrace);
                MessageBox.Show("Please check the error.txt file on your desktop, and send it to the developer.");
                RequireUserInfo(file);
            }
        }
 private void CreateTechnicPermissionInfo(Mcmod mod, PermissionPolicy pl, string customPermissionText, string modlink)
 {
     string ps = string.Format("{0}({1}) by {2}{3}At {4}{3}Permissions are {5}{3}", mod.Name, mod.Modid, GetAuthors(mod), Environment.NewLine, modlink, pl);
     if (!string.IsNullOrWhiteSpace(customPermissionText))
     {
         ps += customPermissionText + Environment.NewLine;
     }
     File.AppendAllText(_technicPermissionList, ps + Environment.NewLine);
 }
 private void CreateTechnicPermissionInfo(Mcmod mod, PermissionPolicy pl, string customPermissionText = null)
 {
     string modlink = _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modAuthors;
     while (string.IsNullOrWhiteSpace(modlink) || !Uri.IsWellFormedUriString(modlink, UriKind.Absolute))
     {
         modlink = Prompt.ShowDialog("What is the link to " + mod.Name + "?", "Mod link", false, Prompt.ModsLeftString(_totalMods, _currentMod));
         if (!Uri.IsWellFormedUriString(modlink, UriKind.Absolute))
         {
             MessageBox.Show("Not a proper url");
         }
     }
     CreateTechnicPermissionInfo(mod, pl, customPermissionText, modlink);
 }
        public void CreateTechnicModZip(Mcmod mod, string modfile)
        {
            if (mod.IsSkipping)
            {
                return;
            }
            string fileName = modfile.Substring(modfile.LastIndexOf(Globalfunctions.PathSeperator) + 1);
            string modMd5 = SqlHelper.CalculateMd5(modfile);
            _modsSqLhelper.AddMod(mod.Name, mod.Modid, mod.Version, mod.Mcversion, fileName, modMd5, false);
            # region permissions
            if (TechnicPermissions.Checked)
            {
                PermissionPolicy permissionPolicy = _ftbPermsSqLhelper.FindPermissionPolicy(mod.Modid, TechnicPublicPermissions.Checked);
                string overwritelink;
                OwnPermissions ownPermissions;
                string customPermissionText;
                switch (permissionPolicy)
                {
                    case PermissionPolicy.Open:
                        CreateTechnicPermissionInfo(mod, permissionPolicy);
                        break;
                    case PermissionPolicy.Notify:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog(mod.Name + " requires that you notify the author of inclusion." + Environment.NewLine + "Please provide proof(an imgur link) that you have done this:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink);
                                        customPermissionText = "Proof of notitification: " + overwritelink;
                                        CreateTechnicPermissionInfo(mod, permissionPolicy, customPermissionText, _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modLink);
                                        break;
                                    }
                                }
                                overwritelink = Prompt.ShowDialog(mod.Name + " requires that you notify the author of inclusion." + Environment.NewLine + "Please provide proof(an imgur link) that you have done this:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            }
                        }
                        else
                        {
                            customPermissionText = "Proof of notitification: " + ownPermissions.PermissionLink;
                            CreateTechnicPermissionInfo(mod, permissionPolicy, customPermissionText);
                        }
                        break;
                    case PermissionPolicy.FTB:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog("Permissions for " + mod.Name + " is FTB exclusive" + Environment.NewLine + "Please provide proof(an imgur link) of things being otherwise:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink, _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modLink);
                                        break;
                                    }
                                }
                                overwritelink = Prompt.ShowDialog("Permissions for " + mod.Name + " is FTB exclusive" + Environment.NewLine + "Please provide proof(an imgur link) of things being otherwise:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            }
                        }
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        customPermissionText = "Proof of permission outside of FTB: " + ownPermissions.PermissionLink;
                        CreateTechnicPermissionInfo(mod, permissionPolicy, customPermissionText, ownPermissions.ModLink);
                        break;
                    case PermissionPolicy.Request:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog("This mod requires that you request permissions from the Mod Author of " + mod.Name + Environment.NewLine + "Please provide proof(an imgur link) that you have this permission:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name);
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink, _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modLink);
                                        break;
                                    }
                                }
                                overwritelink = Prompt.ShowDialog("This mod requires that you request permissions from the Mod Author of " + mod.Name + Environment.NewLine + "Please provide proof(an imgur link) that you have this permission:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            }
                        }
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        customPermissionText = GetAuthors(mod) + " has given permission as seen here: " + ownPermissions.PermissionLink;
                        CreateTechnicPermissionInfo(mod, permissionPolicy, customPermissionText, ownPermissions.ModLink);
                        break;
                    case PermissionPolicy.Closed:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog("The FTB permissionsheet states that permissions for " + mod.Name + " is closed." + Environment.NewLine + "Please provide proof(an imgur link) that this is not the case:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink, _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modLink);
                                        break;
                                    }
                                }
                                overwritelink = Prompt.ShowDialog("The FTB permissionsheet states that permissions for " + mod.Name + " is closed." + Environment.NewLine + "Please provide proof(an imgur link) that this is not the case:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name);
                            }
                        }
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        customPermissionText = GetAuthors(mod) + " has given permission as seen here: " + ownPermissions.PermissionLink;
                        CreateTechnicPermissionInfo(mod, permissionPolicy, customPermissionText, ownPermissions.ModLink);
                        break;
                    case PermissionPolicy.Unknown:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        var modLink = ownPermissions.ModLink;
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog("Permissions for " + mod.Name + " is unknown" + Environment.NewLine + "Please provide proof(an imgur link) of permissions:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        break;
                                    }
                                }
                                overwritelink = Prompt.ShowDialog("Permissions for " + mod.Name + " is unknown" + Environment.NewLine + "Please provide proof(an imgur link) of permissions:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            }
                            while (string.IsNullOrWhiteSpace(modLink))
                            {
                                if (modLink != null && modLink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (modLink != null && Uri.IsWellFormedUriString(modLink, UriKind.Absolute))
                                {
                                    _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink, modLink);
                                    break;

                                }
                                modLink = Prompt.ShowDialog("Please provide a link to " + mod.Name + ":" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            }
                            string a = GetAuthors(mod);
                            _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink, modLink);
                            CreateOwnPermissionInfo(mod.Name, mod.Modid, a, overwritelink, modLink);

                        }
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        customPermissionText = GetAuthors(mod) + " has given permission as seen here: " + ownPermissions.PermissionLink;
                        CreateTechnicPermissionInfo(mod, permissionPolicy, customPermissionText, ownPermissions.ModLink);
                        break;
                }
            }
            # endregion
            if (SolderPack.Checked)
            {
                bool force = forcesolder.Checked;
                bool useSolderBool = useSolder.Checked;
                BackgroundWorker bw = new BackgroundWorker();
                _runningProcess++;
                bw.DoWork += (o, arg) =>
                {

                    var modid = mod.Modid.Contains("|")
                        ? mod.Modid.Replace("|", "+")
                            .Replace(".", string.Empty)
                            .ToLower()
                        : mod.Modid.Replace(".", string.Empty).ToLower();
                    string modversion = mod.Mcversion.ToLower() + "-" + mod.Version.ToLower();
                    if (useSolderBool && !force)
                    {
                        if (_solderSqlHandler.IsModversionOnline(modid, modversion))
                        {
                            Debug.WriteLine(modid + " is already online with version " + modversion);
                            int id = _solderSqlHandler.GetModId(modid);
                            int modVersionId = _solderSqlHandler.GetModversionId(id, modversion);
                            _solderSqlHandler.AddModversionToBuild(_buildId, modVersionId);
                            _runningProcess--;
                            return;
                        }
                    }

                    while (true)
                    {
                        if (_processesUsingModID.ContainsKey(mod.Modid))
                        {
                            Debug.WriteLine("Sleeping with id: " + mod.Modid);
                            Thread.Sleep(100);
                        }
                        else
                        {
                            _processesUsingModID.Add(mod.Modid, 1);
                            break;
                        }
                    }

                    if (!_modsSqLhelper.IsFileInSolder(modfile) || force)
                    {
                        var modDir = Path.Combine(_outputDirectory, "mods",
                            mod.Modid.Contains("|")
                                ? mod.Modid.Replace("|", "+")
                                    .Replace(".", string.Empty)
                                    .ToLower()
                                    .Replace(Globalfunctions.PathSeperator.ToString(), string.Empty)
                                : mod.Modid.Replace(".", string.Empty)
                                    .ToLower()
                                    .Replace(Globalfunctions.PathSeperator.ToString(), string.Empty), "mods");
                        Directory.CreateDirectory(modDir);
                        if (_processesUsingFolder.ContainsKey(modDir))
                        {
                            _processesUsingFolder[modDir]++;
                        }
                        else
                        {
                            _processesUsingFolder.Add(modDir, 1);
                        }
                        string tempModFile = Path.Combine(modDir, fileName);

                        string tempFileDirectory =
                            tempModFile.Remove(tempModFile.LastIndexOf(Globalfunctions.PathSeperator));

                        Directory.CreateDirectory(tempFileDirectory);
                        File.Copy(modfile, tempModFile, true);

                        var modArchive = mod.Modid.Contains("|")
                            ? Path.Combine(_outputDirectory, "mods",
                                mod.Modid.Replace("|", "+")
                                    .Replace(".", string.Empty)
                                    .ToLower(),
                                mod.Modid.Replace("|", "+")
                                    .Replace(".", string.Empty)
                                    .ToLower() + "-" + mod.Mcversion.ToLower() + "-" + mod.Version.ToLower() + ".zip")
                            : Path.Combine(_outputDirectory, "mods", mod.Modid.Replace(".", string.Empty).ToLower(),
                                mod.Modid.Replace(".", string.Empty).ToLower() + "-" + mod.Mcversion.ToLower() + "-" +
                                mod.Version.ToLower() + ".zip");
                        if (Globalfunctions.IsUnix())
                        {
                            Environment.CurrentDirectory = Path.Combine(_outputDirectory, "mods",
                                mod.Modid.Contains("|")
                                    ? mod.Modid.Replace("|", "+")
                                        .Replace(".", string.Empty)
                                        .ToLower()
                                    : mod.Modid.Replace(".", string.Empty).ToLower());
                            _startInfo.FileName = "zip";
                            _startInfo.Arguments = "-r \"" + modArchive + "\" \"mods\" ";
                        }
                        else
                        {
                            _startInfo.Arguments = "a -y \"" + modArchive + "\" \"" + modDir + "\" ";
                        }
                        Process process = new Process { StartInfo = _startInfo };

                        process.Start();

                        //Save mod to database
                        _modsSqLhelper.AddMod(mod.Name, mod.Modid, mod.Version, mod.Mcversion, fileName, modMd5, true);

                        // Add mod info to a html file
                        CreateTableRow(mod.Name.Replace("|", "+"), modid, modversion);

                        process.WaitForExit();

                        if (useSolderBool)
                        {
                            int id = -1;
                            string archive = Path.Combine(_outputDirectory, "mods", modArchive);
                            SolderSqlHandler sqh = new SolderSqlHandler();
                            string md5Value = SqlHelper.CalculateMd5(archive).ToLower();
                            if (sqh.IsModversionOnline(modid, modversion))
                            {
                                Debug.WriteLine(string.Format("Updating mod on solder with Modid: {0} modversion: {1} md5value: {2}", modid, modversion, md5Value), doDebug.Checked);
                                sqh.UpdateModversionMd5(modid, modversion, md5Value);
                                Debug.WriteLine(string.Format("Done updating mod on solder with modid: {0}", modid));
                            }
                            else
                            {
                                id = sqh.GetModId(modid);
                                if (id == -1)
                                {
                                    sqh.AddModToSolder(modid, mod.Description, GetAuthors(mod), mod.Url,
                                        mod.Name);
                                }
                                Debug.WriteLine(string.Format("Adding mod to solder with Modid: {0} modversion: {1} md5value: {2}", modid, modversion, md5Value), doDebug.Checked);
                                sqh.AddNewModversionToSolder(modid, modversion, md5Value);
                            }
                            id = sqh.GetModId(modid);
                            int modVersionId = sqh.GetModversionId(id, modversion);
                            sqh.AddModversionToBuild(_buildId, modVersionId);
                            Debug.WriteLine(string.Format("Done addong mod {0} to build", modid));
                        }
                        Debug.WriteLine("Decrementing " + modDir);
                        _processesUsingFolder[modDir]--;
                        Debug.WriteLine("Decremented " + modDir);
                        if (Directory.Exists(modDir) && _processesUsingFolder[modDir] == 0)
                        {
                            while (true)
                            {
                                try
                                {
                                    Debug.WriteLine("Attempting to delete directory " + modDir);
                                    Directory.Delete(modDir, true);
                                    Debug.WriteLine("Done deleting directory " + modDir);
                                    break;
                                }
                                catch (IOException e)
                                {
                                    Debug.WriteLine(e.Message);
                                    Thread.Sleep(100);
                                }
                            }
                            _processesUsingFolder.Remove(modDir);
                        }
                    }
                    if (_processesUsingModID.ContainsKey(mod.Modid))
                        if (_processesUsingModID[mod.Modid] > 1)
                        {
                            _processesUsingModID[mod.Modid]--;
                        }
                        else
                        {
                            _processesUsingModID.Remove(mod.Modid);
                        }
                    _runningProcess--;
                    Debug.WriteLine("Decremented _runningProcess");
                };
                bw.RunWorkerAsync();
            }
            else
            {
                _modsSqLhelper.AddMod(mod.Name, mod.Modid, mod.Version, mod.Mcversion, fileName, modMd5, false);
                while (string.IsNullOrWhiteSpace(_modpackName))
                {
                    _modpackName = Prompt.ShowDialog("What is the Modpack Name?", "Modpack Name");
                }
                while (string.IsNullOrWhiteSpace(_modpackVersion))
                {
                    _modpackVersion = Prompt.ShowDialog("What Version is the modpack?", "Modpack Version");
                }

                string tempDirectory = Path.Combine(_outputDirectory, "tmp");
                string tempModDirectory = Path.Combine(tempDirectory, "mods");
                Directory.CreateDirectory(tempModDirectory);
                string tempFile = Path.Combine(tempModDirectory, fileName);

                int index = tempFile.LastIndexOf(Globalfunctions.PathSeperator);

                string tempFileDirectory = tempFile.Remove(index);
                Directory.CreateDirectory(tempFileDirectory);
                File.Copy(modfile, tempFile, true);

                _modpackArchive = Path.Combine(_outputDirectory, string.Format("{0}-{1}.zip", _modpackName, _modpackVersion));

                if (Globalfunctions.IsUnix())
                {
                    Environment.CurrentDirectory = tempDirectory;
                    _startInfo.Arguments = string.Format("-r \"{0}\" \"{1}\"", _modpackArchive, "mods");
                }
                else
                {
                    _startInfo.Arguments = string.Format("a -y \"{0}\" \"{1}\"", _modpackArchive, tempModDirectory);
                }
                if (Globalfunctions.IsUnix())
                {
                    _startInfo.FileName = "zip";
                }
                _process.StartInfo = _startInfo;
                _process.Start();
                _process.WaitForExit();
                Directory.Delete(tempDirectory, true);
            }

            if (mod.HasBeenWritenToModlist)
                return;
            File.AppendAllText(_modlistTextFile, mod.Name + Environment.NewLine);
            mod.HasBeenWritenToModlist = true;
        }
        // waila-1.5.5_1.7.10.jar
        public static Mcmod WailaPattern(String fileName)
        {
            fileName = fileName.Remove(fileName.LastIndexOf(".", StringComparison.Ordinal));
            Mcmod mod = new Mcmod();

            String name = "";
            foreach (char c in fileName)
            {
                if (!(c.Equals('-')))
                {
                    name = name + c;
                }
                else
                {
                    break;
                }
            }
            mod.Name = name;

            fileName = fileName.Replace(name, "");

            String version = "";
            foreach (char c in fileName)
            {
                if (!(c.Equals('_')))
                {
                    version = version + c;
                }
                else
                {
                    break;
                }
            }
            mod.Version = version;

            fileName = fileName.Replace("_", "").Replace(version, "");
            mod.Mcversion = fileName;

            return mod;
        }
 private static Boolean IsFullyInformed(Mcmod mod)
 {
     if (String.IsNullOrWhiteSpace(mod.Name) || String.IsNullOrWhiteSpace(mod.Version) ||
         String.IsNullOrWhiteSpace(mod.Mcversion) || String.IsNullOrWhiteSpace(mod.Modid) || (mod.AuthorList == null && mod.Authors == null))
         return false;
     Debug.WriteLine(mod.Version);
     if (mod.Name.Contains("${") || mod.Version.Contains("${") || mod.Mcversion.Contains("${") || mod.Modid.Contains("${") || mod.Version.ToLower().Contains("@version@") || mod.Modid.ToLower().Contains("example") || mod.Version.ToLower().Contains("example") || mod.Name.ToLower().Contains("example"))
     {
         return false;
     }
     return true;
 }
        private void RequireUserInfo(String file)
        {
            Mcmod mod = new Mcmod { Mcversion = null, Modid = null, Name = null, Version = null };

            RequireUserInfo(mod, file);
        }
        public static Mcmod ReikasMods(String fileName)
        {
            Mcmod mod = new Mcmod();

            fileName = fileName.Remove(fileName.LastIndexOf(".", StringComparison.Ordinal));

            //Figure out mod name
            String[] reikas = fileName.Split(' ');

            mod.Name = reikas[0].Replace(" ", String.Empty);
            mod.Mcversion = reikas[1].Replace(" ", String.Empty);
            mod.Version = reikas[2].Replace(" ", String.Empty);

            return mod;
        }
        private void Start()
        {
            if (Prepare())
            {
                return;
            }
            AddedModStringBuilder.Clear();
            List<String> files = GetModFiles();
            StatusLabel.Text = "Finding Files";
            while (String.IsNullOrWhiteSpace(_modpackName))
            {
                _modpackName = Prompt.ShowDialog("What is the Modpack Name?", "Modpack Name");
            }
            while (String.IsNullOrWhiteSpace(_modpackVersion))
            {
                _modpackVersion = Prompt.ShowDialog("What Version is the modpack?", "Modpack Version");
            }
            if (String.IsNullOrWhiteSpace(_modpackArchive))
            {
                _modpackArchive = Path.Combine(_outputDirectory, String.Format("{0}-{1}.zip", _modpackName, _modpackVersion));
            }
            _ftbModpackArchive = Path.Combine(_outputDirectory, _modpackName + "-" + _modpackVersion + "-FTB" + ".zip");

            if (String.IsNullOrWhiteSpace(_currentMcVersion))
            {
                Mcselector selector = new Mcselector(this);
                selector.ShowDialog();
            }

            if (useSolder.Checked)
            {
                initializeSolderSqlHandler();
            }

            _processesUsingModID.Clear();

            List<Mcmod> modsList = new List<Mcmod>(_totalMods);
            toolStripProgressBar.Value = 0;
            toolStripProgressBar.Maximum = _totalMods;
            //Check if files have already been added
            foreach (String file in files)
            {
                Debug.WriteLine("");
                _currentMod++;
                toolStripProgressBar.Increment(1);
                if (IsWierdMod(file) == 0)
                {
                    continue;
                }
                // ReSharper disable once InconsistentNaming
                var FileName = file.Substring(file.LastIndexOf(Globalfunctions.PathSeperator) + 1);
                //Check for mcmod.info
                StatusLabel.Text = FileName;
                Directory.CreateDirectory(_outputDirectory);
                Mcmod tmpMod = _modsSqLhelper.GetModInfo(SqlHelper.CalculateMd5(file));
                if (tmpMod != null)
                {
                    if (missingInfoActionOnTheRun.Checked)
                    {
                        if (IsFullyInformed(tmpMod))
                        {
                            if (CreateTechnicPack.Checked)
                            {
                                CreateTechnicModZip(tmpMod, file);
                            }
                            if (CreateFTBPack.Checked)
                            {
                                CreateFtbPackZip(tmpMod, file);
                            }
                        }
                        else
                        {
                            RequireUserInfo(tmpMod, file);
                        }
                    }
                    else
                    {
                        tmpMod.Filename = FileName;
                        tmpMod.Path = file;
                        modsList.Add(tmpMod);
                    }
                    continue;
                }
                String arguments;
                if (Globalfunctions.IsUnix())
                {
                    _startInfo.FileName = "unzip";
                    arguments = string.Format("-o \"{0}\" \"*.info\" \"*.json\" -d \"{1}\"", file, _outputDirectory);
                }
                else
                {
                    arguments = string.Format("e -y -o\"{0}\" \"{1}\" *.info litemod.json", _outputDirectory, file);
                }
                _startInfo.Arguments = arguments;

                _process.StartInfo = _startInfo;
                _process.Start();
                _process.WaitForExit();
                String mcmodfile = Path.Combine(_outputDirectory, "mcmod.info");
                String litemodfile = Path.Combine(_outputDirectory, "litemod.json");
                if (File.Exists(litemodfile))
                {
                    if (File.Exists(mcmodfile))
                    {
                        File.Delete(mcmodfile);
                    }
                    File.Move(litemodfile, mcmodfile);
                }
                if (!File.Exists(mcmodfile))
                {
                    foreach (String modinfofile in Directory.GetFiles(_outputDirectory, "*.info"))
                    {
                        if (modinfofile.ToLower().Contains("dependancies") ||
                            modinfofile.ToLower().Contains("dependencies"))
                            File.Delete(modinfofile);
                        else
                        {
                            if (!File.Exists(mcmodfile))
                                File.Move(modinfofile, mcmodfile);
                            else
                            {
                                File.Delete(mcmodfile);
                                File.Move(modinfofile, mcmodfile);
                            }
                        }
                    }
                }

                if (File.Exists(mcmodfile))
                {

                    //If exist, then read info and make zip file
                    String json;
                    using (StreamReader r = new StreamReader(mcmodfile))
                    {
                        json = r.ReadToEnd();
                    }
                    try
                    {
                        try
                        {
                            Mcmod2 modinfo2;
                            try
                            {
                                modinfo2 = JsonConvert.DeserializeObject<Mcmod2>(json);
                            }
                            catch (JsonReaderException)
                            {
                                MessageBox.Show(string.Format("Something is wrong with the Json in {0}", FileName));
                                throw new JsonSerializationException("Invalid Json in file" + FileName);
                            }

                            Mcmod mod = new Mcmod();

                            if (modinfo2.Modinfoversion != 0 && modinfo2.Modinfoversion > 1 || modinfo2.ModListVersion != 0 && modinfo2.ModListVersion > 1)
                            {
                                mod.Mcversion = modinfo2.Modlist[0].Mcversion;
                                mod.Modid = modinfo2.Modlist[0].Modid;
                                mod.Name = modinfo2.Modlist[0].Name;
                                mod.Version = modinfo2.Modlist[0].Version;
                                mod.Authors = modinfo2.Modlist[0].Authors;
                                mod.Description = modinfo2.Modlist[0].Description;
                                mod.Url = modinfo2.Modlist[0].Url;
                                if (missingInfoActionOnTheRun.Checked)
                                {
                                    RequireUserInfo(mod, file);
                                }
                                else
                                {
                                    mod.Filename = FileName;
                                    mod.Path = file;
                                    modsList.Add(mod);
                                }
                            }
                            else
                            {
                                throw new JsonSerializationException();
                            }
                        }
                        catch (JsonSerializationException)
                        {
                            try
                            {
                                List<Mcmod> modinfo;
                                try
                                {
                                    modinfo = JsonConvert.DeserializeObject<List<Mcmod>>(json);
                                }
                                catch (JsonReaderException)
                                {
                                    MessageBox.Show(string.Format("Something is wrong with the Json in {0}", FileName));
                                    throw new JsonSerializationException("Invalid Json in file" + FileName);
                                }
                                var mod = modinfo[0];
                                if (!String.IsNullOrWhiteSpace(mod.Version))
                                {
                                    mod.Version = mod.Version.Replace(" ", "-");
                                }
                                if (missingInfoActionOnTheRun.Checked)
                                {
                                    if (IsFullyInformed(mod))
                                    {
                                        if (CreateTechnicPack.Checked)
                                        {
                                            CreateTechnicModZip(mod, file);
                                        }
                                        if (CreateFTBPack.Checked)
                                        {
                                            CreateFtbPackZip(mod, file);
                                        }
                                    }
                                    else
                                    {
                                        RequireUserInfo(mod, file);
                                    }
                                }
                                else
                                {
                                    mod.Filename = FileName;
                                    mod.Path = file;
                                    modsList.Add(mod);
                                }

                            }
                            catch (JsonSerializationException)
                            {
                                Litemod liteloadermod;

                                try
                                {
                                    liteloadermod = JsonConvert.DeserializeObject<Litemod>(json);
                                }
                                catch (JsonReaderException)
                                {
                                    MessageBox.Show(string.Format("Something is wrong with the Json in {0}", FileName));
                                    throw new JsonSerializationException("Invalid Json in file" + FileName);
                                }
                                //Convert into mcmod
                                Mcmod mod = new Mcmod
                                {
                                    Mcversion = liteloadermod.Mcversion,
                                    Modid = liteloadermod.Name.Replace(" ", ""),
                                    Name = liteloadermod.Name,
                                    Description = liteloadermod.Description,
                                    Authors = new List<string> { liteloadermod.Author }
                                };

                                if (String.IsNullOrEmpty(liteloadermod.Version) || String.IsNullOrEmpty(liteloadermod.Revision))
                                {
                                    if (!(String.IsNullOrEmpty(liteloadermod.Version)))
                                    {
                                        mod.Version = liteloadermod.Version;
                                    }
                                    else
                                    {
                                        if (!(String.IsNullOrEmpty(liteloadermod.Revision)))
                                        {
                                            mod.Version = liteloadermod.Revision;
                                        }
                                    }
                                }
                                else
                                {
                                    mod.Version = liteloadermod.Version + "-" + liteloadermod.Revision;
                                }
                                if (missingInfoActionOnTheRun.Checked)
                                {
                                    RequireUserInfo(mod, file);
                                }
                                else
                                {
                                    mod.Filename = FileName;
                                    mod.Path = file;
                                    modsList.Add(mod);
                                }

                            }
                        }

                    }
                    catch (JsonSerializationException)
                    {
                        RequireUserInfo(file);
                    }
                    File.Delete(mcmodfile);
                }
                else
                {

                    //Check the FTB permission sheet for info before doing anything else
                    String shortname = _ftbPermsSqLhelper.GetShortName(SqlHelper.CalculateMd5(file));
                    if (String.IsNullOrWhiteSpace(shortname))
                    {
                        int fixNr = IsWierdMod(FileName);
                        if (fixNr != Int32.MaxValue)
                        {
                            Mcmod mod;
                            switch (fixNr)
                            {
                                case 1:
                                    Liteloaderversion llversion = _liteloaderSqlHelper.GetInfo(SqlHelper.CalculateMd5(file));
                                    mod = new Mcmod
                                    {
                                        Mcversion = llversion.Mcversion,
                                        Name = "Liteloader",
                                        Modid = llversion.TweakClass
                                    };
                                    try
                                    {
                                        mod.Version = llversion.Version.Substring(llversion.Version.LastIndexOf("_", StringComparison.Ordinal) + 1);
                                    }
                                    catch (NullReferenceException)
                                    {
                                        mod.Version = 1.ToString();
                                    }
                                    if (missingInfoActionOnTheRun.Checked)
                                    {
                                        RequireUserInfo(mod, file);
                                    }
                                    else
                                    {
                                        mod.Filename = FileName;
                                        mod.Path = file;
                                        modsList.Add(mod);
                                    }
                                    break;
                            }
                        }
                        else
                        {
                            if (missingInfoActionOnTheRun.Checked)
                            {
                                RequireUserInfo(file);
                            }
                            else
                            {
                                modsList.Add(new Mcmod
                                {
                                    Path = file,
                                    Filename = FileName
                                });
                            }
                        }
                    }
                    else
                    {
                        Mcmod mod = new Mcmod();
                        if (shortname.Equals("ignore"))
                        {
                            mod.IsIgnore = true;
                        }
                        else
                        {
                            mod.IsIgnore = false;
                            mod.UseShortName = true;
                            mod.Modid = shortname;
                            mod.Name = _ftbPermsSqLhelper.GetPermissionFromModId(shortname).modName;
                            mod.Authors = new List<string>
                            {
                                _ftbPermsSqLhelper.GetPermissionFromModId(shortname).modAuthors
                            };
                            mod.AuthorList = mod.Authors;
                            mod.PrivatePerms = _ftbPermsSqLhelper.FindPermissionPolicy(shortname, false);
                            mod.PublicPerms = _ftbPermsSqLhelper.FindPermissionPolicy(shortname, true);
                        }

                        if (missingInfoActionOnTheRun.Checked)
                        {
                            if (CreateFTBPack.Checked && !CreateTechnicPack.Checked)
                                CreateFtbPackZip(mod, file);
                            else
                            {
                                if (CreateFTBPack.Checked || CreateTechnicPack.Checked)
                                    RequireUserInfo(mod, file);
                            }
                        }
                        else
                        {
                            mod.Filename = FileName;
                            mod.Path = file;
                            modsList.Add(mod);
                        }
                    }
                }
            }
            if (missingInfoActionCreateList.Checked)
            {
                StatusLabel.Text = "Showing modlistpane.";
                toolStripProgressBar.Value = toolStripProgressBar.Maximum;
                Form modinfo = new Modinfo(modsList, this);
                if (!modinfo.IsDisposed)
                {
                    modinfo.ShowDialog();
                }
            }

            Environment.CurrentDirectory = _inputDirectory;
            String[] directories = Directory.GetDirectories(_inputDirectory);
            const string minecraftVersionPattern = @"^[0-9]{1}\.[0-9]{1}\.[0-9]{1,2}$";
            foreach (String dir in directories)
            {
                StatusLabel.Text = "Packing additional folders";

                String dirName = dir.Substring(dir.LastIndexOf(Globalfunctions.PathSeperator) + 1);
                if (Regex.IsMatch(dirName, minecraftVersionPattern, RegexOptions.Multiline))
                {
                    continue;
                }
                String[] jarFiles = Directory.GetFiles(dir, "*.jar", SearchOption.AllDirectories);
                if (jarFiles.Length != 0)
                {
                    continue;
                }
                String levelOverInputDirectory = _inputDirectory.Remove(_inputDirectory.LastIndexOf(Globalfunctions.PathSeperator));

                DialogResult confirmInclude = MessageBox.Show(string.Format("Do you want to include {0}?", dirName),
                                                  @"Additional folder found", MessageBoxButtons.YesNo);
                if (confirmInclude == DialogResult.Yes)
                {
                    Environment.CurrentDirectory = levelOverInputDirectory;
                    if (CreateTechnicPack.Checked)
                    {
                        //Create Technic Pack
                        if (SolderPack.Checked)
                        {
                            List<String> md5Values = new List<string>();
                            List<String> oldmd5Values = new List<string>();
                            Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SolderHelper", "unarchievedFiles"));
                            String md5ValuesFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SolderHelper", "unarchievedFiles", dirName + ".txt");
                            if (File.Exists(md5ValuesFile))
                            {
                                using (StreamReader reader = new StreamReader(md5ValuesFile))
                                {
                                    while (true)
                                    {
                                        String tmp = reader.ReadLine();
                                        if (String.IsNullOrWhiteSpace(tmp))
                                            break;
                                        oldmd5Values.Add(tmp);
                                    }
                                }
                            }

                            bool same = true;
                            foreach (String f in Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories))
                            {
                                if (!oldmd5Values.Contains(SqlHelper.CalculateMd5(f)))
                                {
                                    same = false;
                                }
                                md5Values.Add(SqlHelper.CalculateMd5(f));
                            }
                            if (same)
                            {
                                continue;
                            }
                            while (String.IsNullOrWhiteSpace(_modpackVersion))
                            {
                                _modpackVersion = Prompt.ShowDialog("What Version is the modpack?", "Modpack Version");
                            }
                            //So we need to include this folder
                            Environment.CurrentDirectory = levelOverInputDirectory;
                            String outputfile = Path.Combine(_outputDirectory, "mods", dirName.ToLower(), dirName.ToLower() + "-" + MakeUrlFriendly(_modpackName + "-" + _modpackVersion) + ".zip");
                            Directory.CreateDirectory(Path.Combine(_outputDirectory, "mods", dirName.ToLower()));
                            if (Globalfunctions.IsUnix())
                            {
                                _startInfo.FileName = "zip";
                                _startInfo.Arguments = String.Format("-r \"{0}\" mods/{1}", outputfile, dirName);
                            }
                            else
                            {
                                _startInfo.FileName = _sevenZipLocation;
                                _startInfo.Arguments = String.Format("a -y \"{0}\" \"mods\\{1}\"", outputfile, dirName);
                            }
                            _process.StartInfo = _startInfo;
                            _process.Start();
                            CreateTableRow(dirName, dirName.ToLower(), MakeUrlFriendly(_modpackName + "-" + _modpackVersion));
                            _process.WaitForExit();

                            if (useSolder.Checked)
                            {
                                int id = _solderSqlHandler.GetModId(dirName.ToLower());
                                if (id == -1)
                                {
                                    _solderSqlHandler.AddModToSolder(dirName.ToLower(), null, null, null, dirName);
                                    id = _solderSqlHandler.GetModId(dirName.ToLower());
                                }
                                String modversion = MakeUrlFriendly(_modpackName + "-" + _modpackVersion);
                                String md5 = SqlHelper.CalculateMd5(outputfile).ToLower();
                                if (_solderSqlHandler.IsModversionOnline(dirName.ToLower(), modversion))
                                    _solderSqlHandler.UpdateModversionMd5(dirName.ToLower(), modversion, md5);
                                else
                                    _solderSqlHandler.AddNewModversionToSolder(id, modversion, md5);

                                id = _solderSqlHandler.GetModId(dirName.ToLower());
                                int modVersionId = _solderSqlHandler.GetModversionId(id, modversion);
                                _solderSqlHandler.AddModversionToBuild(_buildId, modVersionId);
                            }
                            if (File.Exists(md5ValuesFile))
                            {
                                File.Delete(md5ValuesFile);
                            }
                            foreach (String md5Value in md5Values)
                            {
                                File.AppendAllText(md5ValuesFile, md5Value + Environment.NewLine);
                            }
                        }
                        else
                        {
                            if (Globalfunctions.IsUnix())
                            {
                                _startInfo.FileName = "zip";
                                _startInfo.Arguments = String.Format("-r \"{0}\" \"./mods/{1}\"", _modpackArchive, dirName);
                            }
                            else
                            {
                                _startInfo.FileName = _sevenZipLocation;
                                _startInfo.Arguments = String.Format("a -y \"{0}\" \"mods\\{1}\"", _modpackArchive, dirName);
                            }
                            _process.StartInfo = _startInfo;
                            _process.Start();
                            _process.WaitForExit();
                        }
                    }
                    if (CreateFTBPack.Checked)
                    {
                        // Create FTB Pack

                        String tmpDir = Path.Combine(_outputDirectory, "minecraft", "mods");
                        Directory.CreateDirectory(tmpDir);
                        if (Globalfunctions.IsUnix())
                        {
                            _startInfo.FileName = "cp";
                            _startInfo.Arguments = String.Format("-r \"./mods/{0}\" \"{1}\"", dirName, tmpDir);
                            _process.StartInfo = _startInfo;
                            _process.Start();
                            _process.WaitForExit();
                        }
                        else
                        {
                            String input = Path.Combine(_inputDirectory, dirName);
                            DirectoryCopy(input, tmpDir, true);
                        }
                    }
                }

            }

            // Pack additional folders if they are marked
            if (CreateTechnicPack.Checked)
            {

                StatusLabel.Text = "Packing additional selected folders.";
                Environment.CurrentDirectory = _inputDirectory.Remove(_inputDirectory.LastIndexOf(Globalfunctions.PathSeperator));
                foreach (string folderName in from cb in _additionalDirectories where cb.Value.Checked select cb.Key.Substring(cb.Key.LastIndexOf(Globalfunctions.PathSeperator) + 1).ToLower())
                {
                    if (SolderPack.Checked)
                    {
                        bool Solder = useSolder.Checked;
                        var worker = new BackgroundWorker();
                        var name = folderName;
                        worker.DoWork += (sender, args) =>
                        {
                            _runningProcess++;
                            String mpname = _modpackName.Replace(" ", "-").ToLower();
                            String of = Path.Combine(_outputDirectory, "mods", name);
                            Directory.CreateDirectory(of);
                            String outputfile = Path.Combine(of,
                                name.ToLower() + "-" + mpname + "-" + _modpackVersion + ".zip");
                            if (Globalfunctions.IsUnix())
                            {
                                _startInfo.FileName = "zip";
                                _startInfo.Arguments = String.Format("-r \"{0}\" {1}", outputfile, name);
                            }
                            else
                            {
                                _startInfo.FileName = _sevenZipLocation;
                                _startInfo.Arguments = String.Format("a -y \"{0}\" \"{1}\"", outputfile, name);
                            }
                            _process.StartInfo = _startInfo;
                            _process.Start();
                            _process.WaitForExit();

                            CreateTableRow(name, name.ToLower(), mpname + "-" + _modpackVersion);

                            if (Solder)
                            {
                                int id = _solderSqlHandler.GetModId(name.ToLower());
                                if (id == -1)
                                {
                                    _solderSqlHandler.AddModToSolder(name.ToLower(), null, null, null,
                                        name);
                                    id = _solderSqlHandler.GetModId(name.ToLower());
                                }
                                String md5 = SqlHelper.CalculateMd5(outputfile).ToLower();
                                if (_solderSqlHandler.IsModversionOnline(name.ToLower(),
                                    mpname + "-" + _modpackVersion))
                                    _solderSqlHandler.UpdateModversionMd5(name.ToLower(),
                                        mpname + "-" + _modpackVersion, md5);
                                else
                                    _solderSqlHandler.AddNewModversionToSolder(id, mpname + "-" + _modpackVersion,
                                        md5);
                                int modVersionId =
                                    _solderSqlHandler.GetModversionId(
                                        _solderSqlHandler.GetModId(name.ToLower()),
                                        mpname + "-" + _modpackVersion);
                                _solderSqlHandler.AddModversionToBuild(_buildId, modVersionId);
                            }
                            _runningProcess--;
                        };
                        worker.RunWorkerAsync();
                    }
                    else
                    {

                        if (Globalfunctions.IsUnix())
                        {
                            _startInfo.FileName = "zip";
                            _startInfo.Arguments = String.Format("-r \"{0}\" \"{1}\"", _modpackArchive, folderName);
                        }
                        else
                        {
                            _startInfo.FileName = _sevenZipLocation;
                            _startInfo.Arguments = String.Format("a -y \"{0}\" \"{1}\"", _modpackArchive, folderName);
                        }
                        _process.StartInfo = _startInfo;
                        _process.Start();
                        _process.WaitForExit();

                    }
                }
            }
            if (CreateTechnicPack.Checked && IncludeForgeVersion.Checked)
            {
                string selectedBuild = ForgeBuild.SelectedItem.ToString();
                PackForge(selectedBuild);
            }

            if (CreateTechnicPack.Checked && IncludeConfigZip.Checked)
                CreateConfigZip();

            //FTB pack configs
            if (CreateFTBPack.Checked)
            {
                foreach (KeyValuePair<String, CheckBox> cb in _additionalDirectories)
                {
                    if (cb.Value.Checked)
                    {
                        String dirName = cb.Key.Substring(cb.Key.LastIndexOf(Globalfunctions.PathSeperator) + 1);
                        String tmpDir = Path.Combine(_outputDirectory, "minecraft");

                        Directory.CreateDirectory(tmpDir);
                        if (Globalfunctions.IsUnix())
                        {
                            _startInfo.FileName = "cp";
                            _startInfo.Arguments = String.Format("-r \"{0}\" \"{1}\"", dirName, tmpDir);
                            _process.StartInfo = _startInfo;
                            _process.Start();
                            _process.WaitForExit();
                        }
                        else
                        {
                            FileAttributes attr = File.GetAttributes(cb.Key);
                            if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                            {
                                tmpDir = Path.Combine(tmpDir, dirName);
                                DirectoryCopy(cb.Key, tmpDir, true);
                            }
                            else
                            {
                                String outputFile = Path.Combine(tmpDir, dirName);
                                File.Copy(cb.Key, outputFile);
                            }
                        }
                    }
                }

                String tmpConfigDirectory = Path.Combine(_outputDirectory, Path.Combine("minecraft", "config"));
                Directory.CreateDirectory(tmpConfigDirectory);

                String sourceConfigDirectory = InputFolder.Text.Replace(Globalfunctions.PathSeperator + "mods", Globalfunctions.PathSeperator + "config");
                try
                {
                    DirectoryCopy(sourceConfigDirectory, tmpConfigDirectory, true);
                }
                catch (DirectoryNotFoundException)
                {
                    MessageBox.Show("I can't seem to find a config directory for the FTB pack.");
                }

                Environment.CurrentDirectory = _outputDirectory;
                if (Globalfunctions.IsUnix())
                {
                    _startInfo.FileName = "zip";
                    _startInfo.Arguments = String.Format("-r \"{0}\" \"minecraft\" -x minecraft/config/YAMPST.nbt",
                        _ftbModpackArchive);
                }
                else
                    _startInfo.Arguments = string.Format("a -x!minecraft\\config\\YAMPST.nbt -y \"{0}\" \"minecraft\" ", _ftbModpackArchive);

                _process.StartInfo = _startInfo;
                _process.Start();
                _process.WaitForExit();
                Directory.Delete(Path.Combine(_outputDirectory, "minecraft"), true);
            }
            while (_runningProcess > 0)
            {
                StatusLabel.Text = "Waiting for " + _runningProcess + " mod" + (_runningProcess == 1 ? "" : "s") + " to finsh packing";
                if (Globalfunctions.IsUnix ()) {
                    statusStrip.Refresh ();
                    this.Refresh ();
                }
                if (doDebug.Checked)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (string pros in _processesUsingFolder.Keys)
                    {
                        sb.AppendLine(pros);
                    }
                    Debug.WriteLine(sb.ToString());
                }
                Debug.Save();
                Thread.Sleep(100);
            }
            StatusLabel.Text = "Saving mod data";
            _modsSqLhelper.SaveData();
            StatusLabel.Text = "Done saving moddata";

            if (Directory.Exists(Path.Combine(_outputDirectory, "assets")))
                Directory.Delete(Path.Combine(_outputDirectory, "assets"), true);
            if (Directory.Exists(Path.Combine(_outputDirectory, "example")))
                Directory.Delete(Path.Combine(_outputDirectory, "example"), true);
            foreach (String file in Directory.GetFiles(_outputDirectory, "*.info", SearchOption.TopDirectoryOnly))
            {
                File.Delete(file);
            }

            if (CreateTechnicPack.Checked && SolderPack.Checked && !useSolder.Checked)
            {
                File.AppendAllText(_path, AddedModStringBuilder.ToString());
                File.AppendAllText(_path, @"</table><button id=""Reshow"" type=""button"">Unhide Everything</button><p>List autogenerated by TechnicSolderHelper &copy; 2014 - Rasmus Hansen</p></body></html>");
                if (Globalfunctions.IsUnix())
                {
                    Process.Start(_path);
                }
                else
                {
                    try
                    {
                        Process.Start("chrome.exe", "\"" + _path + "\"");
                    }
                    catch (Exception)
                    {
                        try
                        {
                            Process.Start("iexplore", "\"" + _path + "\"");
                        }
                        catch (Exception)
                        {
                            try
                            {
                                Process.Start("firefox.exe", "\"" + _path + "\"");
                            }
                            catch (Exception)
                            {
                                Process.Start("\"" + _path + "\"");
                            }
                        }
                    }
                }

            }
            if (CreateTechnicPack.Checked && SolderPack.Checked && UploadToFTPServer.Checked)
            {
                StatusLabel.Text = "Uploading to FTP";
                UploadingToFTP = true;
                BackgroundWorker bwFtp = new BackgroundWorker();
                bwFtp.DoWork += (s, a) =>
                {
                    if (_ftp == null)
                    {
                        _ftp = new Ftp();
                    }
                    _ftp.UploadFolder(Path.Combine(_outputDirectory, "mods"));
                };
                bwFtp.RunWorkerCompleted += (s, a) =>
                {
                    UploadingToFTP = false;
                    MessageBox.Show("Done uploading to FTP");
                };
                bwFtp.RunWorkerAsync();
            }

            if (CreateTechnicPack.Checked && SolderPack.Checked && UseS3.Checked)
            {
                StatusLabel.Text = "Uploading to S3";
                UploadingToS3 = true;
                BackgroundWorker bwS3 = new BackgroundWorker();
                bwS3.DoWork += (s, a) =>
                {
                    S3 s3Client = new S3();
                    s3Client.UploadFolder(Path.Combine(_outputDirectory, "mods"));
                    UploadingToS3 = false;
                };
                bwS3.RunWorkerCompleted += (s, a) =>
                {
                    UploadingToS3 = false;
                };
                bwS3.RunWorkerAsync();
            }

            InputFolder.Items.Clear();
            try
            {
                InputFolder.Items.AddRange(_inputDirectories.ToArray());
            }
            catch
            {
                // ignored
            }
            toolStripProgressBar.Value = 0;
            StatusLabel.Text = "Waiting...";
        }
 /// <summary>
 /// Check is the mcmod.info file has all the info we need to produce a zip file
 /// </summary>
 /// <param name="mod"></param>
 /// <returns>
 /// Returns true if everything is alright</returns>
 private static bool IsFullyInformed(Mcmod mod)
 {
     if (String.IsNullOrWhiteSpace(mod.Name) || String.IsNullOrWhiteSpace(mod.Version) ||
         String.IsNullOrWhiteSpace(mod.Mcversion) || String.IsNullOrWhiteSpace(mod.Modid) || mod.Modid.ToLower().Contains("example") || mod.Name.ToLower().Contains("example") || mod.Version.ToLower().Contains("example"))
         return false;
     if (mod.Name.Contains("${") || mod.Version.Contains("${") || mod.Mcversion.Contains("${") || mod.Modid.Contains("${") || mod.Version.ToLower().Contains("@version@"))
     {
         return false;
     }
     return true;
 }
 private Boolean AreModDone(Mcmod mod)
 {
     if (!IsFullyInformed(mod)) return false;
     OwnPermissionsSqlHelper ownPermissionsSqlHelper = new OwnPermissionsSqlHelper();
     bool b = ownPermissionsSqlHelper.DoUserHavePermission(mod.Modid).HasPermission;
     if (b)
     {
         return true;
     }
     if (_solderHelper.CreateTechnicPack.Checked && _solderHelper.TechnicPermissions.Checked)
     {
         if (_ftbPermissionsSqlHelper.FindPermissionPolicy(mod.Modid,
             _solderHelper.TechnicPublicPermissions.Checked) != PermissionPolicy.Open)
         {
             return false;
         }
     }
     if (!_solderHelper.CreateFTBPack.Checked) return true;
     PermissionPolicy p = _ftbPermissionsSqlHelper.FindPermissionPolicy(mod.Modid,
         _solderHelper.PublicFTBPack.Checked);
     if (p == PermissionPolicy.Open || p == PermissionPolicy.FTB)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
        public static Mcmod GoodVersioning(String fileName)
        {
            fileName = fileName.Remove(fileName.LastIndexOf("."));
            Mcmod mod = new Mcmod();

            //Figure out modname
            String modname = "";
            foreach (char c in fileName)
            {
                if (!(c.Equals('-')))
                {
                    modname = modname + c;
                }
                else
                {
                    break;
                }
            }
            mod.Name = modname;
            fileName = fileName.Replace(modname + "-", "");

            //Figure out minecraft version
            String mcversion = "";
            foreach (char c in fileName)
            {
                if (!(c.Equals('-')))
                {
                    mcversion = mcversion + c;
                }
                else
                {
                    break;
                }
            }
            mod.Mcversion = mcversion;

            //Figure out modversion
            fileName = fileName.Replace(mcversion + "-", "");
            mod.Version = fileName;

            return mod;
        }