internal string ForgeKeep(string FileText, ForgeY.Root ForgePath, string versionjson, string version)
        {
            ForgeJsonEarly.Root root = JsonConvert.DeserializeObject <ForgeJsonEarly.Root>(FileText);
            JsonConvert.DeserializeObject <ForgeY.Root>(FileText);
            string str = null;

            if (root.minecraftArguments != null)
            {
                JsonConvert.DeserializeObject <ForgeJsonEarly.Root>(versionjson);
                str = str + "{";
                this.SLC.wj(System.Directory.GetCurrentDirectory() + @"\.minecraft\versions\" + version + @"\" + version + ".json", versionjson);
                str = str + this.ForgeJsonY(JsonConvert.DeserializeObject <ForgeY.Root>(versionjson), ForgePath);
                char[]   separator = new char[] { ' ' };
                string[] strArray  = root.minecraftArguments.Split(separator);
                string   str2      = "";
                for (int j = 1; strArray.Length > j; j += 2)
                {
                    if ((((strArray[j - 1][0] == '-') && (strArray[j] != "com.mumfrey.liteloader.launch.LiteLoaderTweaker")) && (strArray[j] != "optifine.OptiFineForgeTweaker")) || (strArray[j][0] == '$'))
                    {
                        if (j != (strArray.Length - 1))
                        {
                            string[] textArray4 = new string[] { str2, strArray[j - 1], " ", strArray[j], " " };
                            str2 = string.Concat(textArray4);
                        }
                        else
                        {
                            str2 = str2 + strArray[j - 1] + " " + strArray[j];
                        }
                    }
                }
                if (str2[str2.Length - 1] == ' ')
                {
                    str2 = str2.Substring(0, str2.Length - 1);
                }
                return(str + ",\"minecraftArguments\": \"" + str2 + "\"}");
            }
            JObject obj2 = (JObject)JsonConvert.DeserializeObject(FileText);

            str = str + "{\"arguments\": {\"game\": [";
            for (int i = 1; (obj2["arguments"]["game"].ToArray <JToken>().Length - 1) > 0; i += 2)
            {
                try
                {
                    obj2["arguments"]["game"][i].ToString();
                    if ((((obj2["arguments"]["game"][i - 1].ToString()[0] == '-') && (obj2["arguments"]["game"][i].ToString() != "com.mumfrey.liteloader.launch.LiteLoaderTweaker")) && (obj2["arguments"]["game"][i].ToString() != "optifine.OptiFineForgeTweaker")) || (obj2["arguments"]["game"][i - 1].ToString()[0] == '$'))
                    {
                        string[] textArray1 = new string[] { str, "\"", obj2["arguments"]["game"][i - 1].ToString(), "\",\"", obj2["arguments"]["game"][i].ToString(), "\"," };
                        str = string.Concat(textArray1);
                    }
                }
                catch (Exception)
                {
                    break;
                }
            }
            str = str.Substring(0, str.Length - 1) + "]},";
            this.SLC.wj(System.Directory.GetCurrentDirectory() + @"\.minecraft\versions\" + version + @"\" + version + ".json", versionjson);
            return(str + this.ForgeJsonY(JsonConvert.DeserializeObject <ForgeY.Root>(versionjson), ForgePath) + "}");
        }
        internal async Task <string> LiteloaderJson(string version)
        {
            if (this.tools.LiteloaderExist(version))
            {
                throw new SquareMinecraftLauncherException("已经安装过了,无需再次安装");
            }
            string idVersion = null;

            foreach (AllTheExistingVersion version2 in this.tools.GetAllTheExistingVersion())
            {
                if (version2.version == version)
                {
                    idVersion = version2.IdVersion;
                }
            }
            LiteloaderList[] liteloaderList = await tools.GetLiteloaderList();

            LiteloaderList libraries = new LiteloaderList();

            foreach (LiteloaderList list2 in liteloaderList)
            {
                if (list2.mcversion == idVersion)
                {
                    libraries = list2;
                    break;
                }
                if (list2.mcversion == liteloaderList[liteloaderList.Length - 1].mcversion)
                {
                    throw new SquareMinecraftLauncherException("该版本不支持安装");
                }
            }
            string file = this.SLC.GetFile(System.Directory.GetCurrentDirectory() + @"\.minecraft\versions\" + version + @"\" + version + ".json");

            ForgeY.Root versionText = JsonConvert.DeserializeObject <ForgeY.Root>(file);
            string      str2        = null;

            str2 = str2 + "{" + this.liteloaderJsonY(versionText, libraries, version);
            ForgeJsonEarly.Root root2      = JsonConvert.DeserializeObject <ForgeJsonEarly.Root>(file);
            string[]            textArray2 = new string[] { str2, ",\"minecraftArguments\": \"", root2.minecraftArguments, " --tweakClass ", libraries.tweakClass, "\"}" };
            return(string.Concat(textArray2));
        }
Esempio n. 3
0
        internal ForgeY.Root screening(ref ForgeY.Root Lib, ForgeY.Root forge)
        {
            ForgeY.Root root = new ForgeY.Root();
            List <ForgeY.LibrariesItem> list = new List <ForgeY.LibrariesItem>();

            for (int i = 0; i < Lib.libraries.Count; i++)
            {
                bool l = false;
                for (int j = 0; j < forge.libraries.Count; j++)
                {
                    if (string.Equals(forge.libraries[j].name.Split(':')[1], Lib.libraries[i].name.Split(':')[1]))
                    {
                        l = true;
                        break;
                    }
                }
                if (!l)
                {
                    list.Add(Lib.libraries[i]);
                }
            }
            root.libraries = list;
            return(root);
        }
        public string ForgeJson(string version, string ForgePath)
        {
            string file = null;

            AllTheExistingVersion[] allTheExistingVersion = this.Tools.GetAllTheExistingVersion();
            foreach (AllTheExistingVersion version2 in allTheExistingVersion)
            {
                if (version2.version == version)
                {
                    string idVersion = version2.IdVersion;
                    break;
                }
                if (version2 == allTheExistingVersion[allTheExistingVersion.Length - 1])
                {
                    throw new SquareMinecraftLauncherException("未找到该版本");
                }
            }
            if (this.Tools.ForgeExist(version))
            {
                this.Tools.UninstallTheExpansionPack(ExpansionPack.Forge, version);
            }
            file = this.SLC.GetFile(System.Directory.GetCurrentDirectory() + @"\.minecraft\versions\" + version + @"\" + version + ".json");
            ForgeJsonEarly.Root root        = JsonConvert.DeserializeObject <ForgeJsonEarly.Root>(file);
            ForgeY.Root         versionText = JsonConvert.DeserializeObject <ForgeY.Root>(file);
            string str2 = null;

            if (root.minecraftArguments != null)
            {
                ForgeJsonEarly.Root root3 = JsonConvert.DeserializeObject <ForgeJsonEarly.Root>(this.SLC.GetFile(ForgePath));
                str2 = str2 + "{" + this.ForgeJsonY(versionText, JsonConvert.DeserializeObject <ForgeY.Root>(this.SLC.GetFile(ForgePath)));
                if (this.Tools.OptifineExist(version))
                {
                    root3.minecraftArguments = root3.minecraftArguments + " --tweakClass optifine.OptiFineForgeTweaker";
                }
                if (this.Tools.LiteloaderExist(version))
                {
                    root3.minecraftArguments = root3.minecraftArguments + " --tweakClass com.mumfrey.liteloader.launch.LiteLoaderTweaker";
                }
                return(str2 + ",\"minecraftArguments\": \"" + root3.minecraftArguments + "\"}");
            }
            JObject obj2 = (JObject)JsonConvert.DeserializeObject(file);
            JObject obj3 = (JObject)JsonConvert.DeserializeObject(this.SLC.GetFile(ForgePath));

            str2 = str2 + "{\"arguments\": {\"game\": [";
            for (int i = 0; (obj2["arguments"]["game"].ToArray <JToken>().Length - 1) > 0; i++)
            {
                try
                {
                    obj2["arguments"]["game"][i].ToString();
                    if ((obj2["arguments"]["game"][i].ToString()[0] == '-') || (obj2["arguments"]["game"][i].ToString()[0] == '$'))
                    {
                        str2 = str2 + "\"" + obj2["arguments"]["game"][i].ToString() + "\",";
                        continue;
                    }
                    if (obj2["arguments"]["game"][i - 1].ToString()[0] == '-')
                    {
                        str2 = str2 + "\"" + obj2["arguments"]["game"][i].ToString() + "\",";
                        continue;
                    }
                }
                catch (Exception)
                {
                }
                break;
            }
            if (this.Tools.OptifineExist(version))
            {
                str2 = str2 + "\"--tweakClass\",\"optifine.OptiFineForgeTweaker\",";
            }
            if (this.Tools.LiteloaderExist(version))
            {
                str2 = str2 + " \"--tweakClass\",\"com.mumfrey.liteloader.launch.LiteLoaderTweaker\",";
            }
            for (int j = 0; (obj3["arguments"]["game"].ToArray().Length - 1) > 0; j++)
            {
                try
                {
                    obj3["arguments"]["game"][j].ToString();
                    str2 = str2 + "\"" + obj3["arguments"]["game"][j].ToString() + "\",";
                }
                catch (Exception)
                {
                    str2 = str2.Substring(0, str2.Length - 1) + "]},";
                    break;
                }
            }
            return(str2 + this.ForgeJsonY(versionText, JsonConvert.DeserializeObject <ForgeY.Root>(this.SLC.GetFile(ForgePath))) + "}");
        }
        public string ForgeJsonY(ForgeY.Root versionText, ForgeY.Root ForgeText)
        {
            string[] textArray1 = new string[] { "\"assetIndex\": {\"id\": \"", versionText.assetIndex.id, "\",\"size\":", versionText.assetIndex.size, ",\"url\": \"", versionText.assetIndex.url, "\"},\"assets\": \"", versionText.assets, "\",\"downloads\": {\"client\": {\"url\":\"", versionText.downloads.client.url, "\"}},\"id\": \"", versionText.id, "\",\"libraries\": [" };
            string   str        = string.Concat(textArray1);

            foreach (ForgeY.LibrariesItem item in ForgeText.libraries)
            {
                if (item.downloads == null)
                {
                    ForgeY.Downloads downloads = new ForgeY.Downloads();
                    ForgeY.Artifact  artifact  = new ForgeY.Artifact();
                    downloads.artifact = artifact;
                    item.downloads     = downloads;
                }
                else if (item.downloads.artifact == null)
                {
                    ForgeY.Artifact artifact2 = new ForgeY.Artifact();
                    item.downloads.artifact = artifact2;
                }
                if (item.downloads.artifact.url == null || item.downloads.artifact.url.IndexOf("files.minecraftforge.net") < 0)
                {
                    item.downloads.artifact.url = "";
                    versionText.libraries.Add(item);
                    continue;
                }
                item.downloads.artifact.url = "http://files.minecraftforge.net/maven/";
                versionText.libraries.Add(item);
            }
            for (int i = 0; versionText.libraries.ToArray().Length > i; i++)
            {
                if (versionText.libraries[i].name == "org.apache.logging.log4j:log4j-api:2.8.1" || versionText.libraries[i].name == "org.apache.logging.log4j:log4j-core:2.8.1" || versionText.libraries[i].name == "net.sf.jopt-simple:jopt-simple:5.0.3")
                {
                    continue;
                }
                str = str + "{\"name\":\"" + versionText.libraries[i].name + "\",";
                if (((versionText.libraries[i].downloads == null) || (versionText.libraries[i].downloads.artifact == null)) && (versionText.libraries[i].url == null))
                {
                    str = str.Substring(0, str.Length - 1);
                }
                else if ((versionText.libraries[i].downloads != null) && (versionText.libraries[i].downloads.artifact != null))
                {
                    str = str + "\"downloads\":{\"artifact\":{\"url\":\"" + versionText.libraries[i].downloads.artifact.url + "\"}}";
                }
                else if (versionText.libraries[i].url != null)
                {
                    str = str + "\"downloads\":{\"artifact\":{\"url\":\"" + versionText.libraries[i].url + "\"}}";
                }
                if (versionText.libraries[i].natives != null)
                {
                    str = str + ",\"natives\": {";
                    string str2 = null;
                    if (versionText.libraries[i].natives.linux != null)
                    {
                        if (str2 != null)
                        {
                            str2 = str2 + ",";
                        }
                        str2 = str2 + "\"linux\": \"natives - linux\"";
                    }
                    if (versionText.libraries[i].natives.osx != null)
                    {
                        if (str2 != null)
                        {
                            str2 = str2 + ",";
                        }
                        str2 = str2 + "\"osx\": \"natives - osx\"";
                    }
                    if (versionText.libraries[i].natives.windows != null)
                    {
                        if (str2 != null)
                        {
                            str2 = str2 + ",";
                        }
                        str2 = str2 + "\"windows\": \"" + versionText.libraries[i].natives.windows + "\"";
                    }
                    str = str + str2 + "}},";
                }
                else
                {
                    str = str + "},";
                }
                if (i == (versionText.libraries.ToArray().Length - 1))
                {
                    char[] chArray1 = str.ToCharArray();
                    chArray1[chArray1.Length - 1] = ']';
                    str = null;
                    foreach (char ch in chArray1)
                    {
                        str = str + ch.ToString();
                    }
                }
            }
            return(str + ",\"mainClass\": \"" + ForgeText.mainClass + "\"");
        }
        public string liteloaderJsonY(ForgeY.Root versionText, LiteloaderList libraries, string version)
        {
            string[] textArray1 = new string[] { "\"assetIndex\": {\"id\": \"", versionText.assetIndex.id, "\",\"size\":", versionText.assetIndex.size, ",\"url\": \"", versionText.assetIndex.url, "\"},\"assets\": \"", versionText.assets, "\",\"downloads\": {\"client\": {\"url\":\"", versionText.downloads.client.url, "\"}},\"id\": \"", versionText.id, "\",\"libraries\": [" };
            string   str        = string.Concat(textArray1);

            foreach (Lib lib in libraries.lib)
            {
                ForgeY.LibrariesItem item2 = new ForgeY.LibrariesItem
                {
                    name = lib.name
                };
                ForgeY.Downloads downloads2 = new ForgeY.Downloads
                {
                    artifact = new ForgeY.Artifact()
                };
                downloads2.artifact.url = " ";
                item2.downloads         = downloads2;
                versionText.libraries.Add(item2);
            }
            ForgeY.LibrariesItem item = new ForgeY.LibrariesItem
            {
                name = "com.mumfrey:liteloader:" + libraries.version
            };
            ForgeY.Downloads downloads = new ForgeY.Downloads
            {
                artifact = new ForgeY.Artifact()
            };
            downloads.artifact.url = this.Minecraft.DownloadLiteloader(libraries.version).Url;
            item.downloads         = downloads;
            versionText.libraries.Add(item);
            for (int i = 0; versionText.libraries.ToArray().Length > i; i++)
            {
                str = str + "{\"name\":\"" + versionText.libraries[i].name + "\",";
                if ((versionText.libraries[i].downloads == null) || (versionText.libraries[i].downloads.artifact == null))
                {
                    str = str.Substring(0, str.Length - 1);
                }
                else
                {
                    str = str + "\"downloads\":{\"artifact\":{\"url\":\"" + versionText.libraries[i].downloads.artifact.url + "\"}}";
                }
                if (versionText.libraries[i].natives != null)
                {
                    str = str + ",\"natives\": {";
                    string str2 = null;
                    if (versionText.libraries[i].natives.linux != null)
                    {
                        if (str2 != null)
                        {
                            str2 = str2 + ",";
                        }
                        str2 = str2 + "\"linux\": \"natives - linux\"";
                    }
                    if (versionText.libraries[i].natives.osx != null)
                    {
                        if (str2 != null)
                        {
                            str2 = str2 + ",";
                        }
                        str2 = str2 + "\"osx\": \"natives - osx\"";
                    }
                    if (versionText.libraries[i].natives.windows != null)
                    {
                        if (str2 != null)
                        {
                            str2 = str2 + ",";
                        }
                        str2 = str2 + "\"windows\": \"" + versionText.libraries[i].natives.windows + "\"";
                    }
                    str = str + str2 + "}},";
                }
                else
                {
                    str = str + "},";
                }
                if (i == (versionText.libraries.ToArray().Length - 1))
                {
                    char[] chArray1 = str.ToCharArray();
                    chArray1[chArray1.Length - 1] = ']';
                    str = null;
                    foreach (char ch in chArray1)
                    {
                        str = str + ch.ToString();
                    }
                }
            }
            return(str + ",\"mainClass\": \"" + versionText.mainClass + "\"");
        }
Esempio n. 7
0
        internal async Task <string> OptifineJson(string version, OptiFineList optiFineList)
        {
            if (this.tools.OptifineExist(version))
            {
                throw new SquareMinecraftLauncherException("已经安装过了,无需再次安装");
            }
            string file = this.SLC.GetFile(System.Directory.GetCurrentDirectory() + @"\.minecraft\versions\" + version + @"\" + version + ".json");

            ForgeJsonEarly.Root root        = JsonConvert.DeserializeObject <ForgeJsonEarly.Root>(file);
            ForgeY.Root         versionText = JsonConvert.DeserializeObject <ForgeY.Root>(file);
            string str2 = null;

            if (root.minecraftArguments == null)
            {
                JObject obj2 = (JObject)JsonConvert.DeserializeObject(file);
                str2 = str2 + "{\"arguments\": {\"game\": [";
                for (int i = 0; (obj2["arguments"]["game"].ToArray <JToken>().Length - 1) > 0; i++)
                {
                    try
                    {
                        obj2["arguments"]["game"][i].ToString();
                        if ((obj2["arguments"]["game"][i].ToString()[0] == '-') || (obj2["arguments"]["game"][i].ToString()[0] == '$'))
                        {
                            str2 = str2 + "\"" + obj2["arguments"]["game"][i].ToString() + "\",";
                            continue;
                        }
                        if (obj2["arguments"]["game"][i - 1].ToString()[0] == '-')
                        {
                            str2 = str2 + "\"" + obj2["arguments"]["game"][i].ToString() + "\",";
                            continue;
                        }
                    }
                    catch (Exception)
                    {
                    }
                    break;
                }
                try
                {
                    await tools.GetCompareForgeVersions(version);

                    str2 = str2 + "\"--tweakClass\",";
                    str2 = str2 + "\"optifine.OptiFineForgeTweaker\"]},";
                }
                catch (SquareMinecraftLauncherException)
                {
                    str2 = str2 + "\"--tweakClass\"," + "\"optifine.OptiFineTweaker\"]},";
                }
                return(str2 + this.liteloaderJsonY(versionText, optiFineList.type, optiFineList.patch, version, optiFineList.filename) + "}");
            }
            str2 = str2 + "{" + this.liteloaderJsonY(versionText, optiFineList.type, optiFineList.patch, version, optiFineList.filename);
            ForgeJsonEarly.Root root3 = JsonConvert.DeserializeObject <ForgeJsonEarly.Root>(file);
            try
            {
                await tools.GetCompareForgeVersions(version);

                return(str2 + ",\"minecraftArguments\": \"" + root3.minecraftArguments + " --tweakClass optifine.OptiFineForgeTweaker\"}");
            }
            catch (SquareMinecraftLauncherException)
            {
                return(str2 + ",\"minecraftArguments\": \"" + root3.minecraftArguments + " --tweakClass optifine.OptiFineTweaker\"}");
            }
        }
Esempio n. 8
0
        internal string liteloaderJsonY(ForgeY.Root versionText, string type, string patch, string version, string filename)
        {
            string[] textArray1 = new string[] { "\"assetIndex\": {\"id\": \"", versionText.assetIndex.id, "\",\"size\":", versionText.assetIndex.size, ",\"url\": \"", versionText.assetIndex.url, "\"},\"assets\": \"", versionText.assets, "\",\"downloads\": {\"client\": {\"url\":\"", versionText.downloads.client.url, "\"}},\"id\": \"", versionText.id, "\",\"libraries\": [" };
            string   str        = string.Concat(textArray1);

            ForgeY.LibrariesItem item       = new ForgeY.LibrariesItem();
            string[]             textArray2 = new string[] { "optifine:OptiFine:", versionText.id, "_", type, "_", patch };
            item.name = string.Concat(textArray2);
            ForgeY.Artifact  artifact  = new ForgeY.Artifact();
            ForgeY.Downloads downloads = new ForgeY.Downloads();
            artifact.url       = this.Minecraft.DownloadOptifine(version, filename).Url;
            downloads.artifact = artifact;
            item.downloads     = downloads;
            versionText.libraries.Add(item);
            for (int i = 0; versionText.libraries.ToArray().Length > i; i++)
            {
                str = str + "{\"name\":\"" + versionText.libraries[i].name + "\",";
                if ((versionText.libraries[i].downloads == null) || (versionText.libraries[i].downloads.artifact == null))
                {
                    str = str.Substring(0, str.Length - 1);
                }
                else
                {
                    str = str + "\"downloads\":{\"artifact\":{\"url\":\"" + versionText.libraries[i].downloads.artifact.url + "\"}}";
                }
                if (versionText.libraries[i].natives != null)
                {
                    str = str + ",\"natives\": {";
                    string str2 = null;
                    if (versionText.libraries[i].natives.linux != null)
                    {
                        if (str2 != null)
                        {
                            str2 = str2 + ",";
                        }
                        str2 = str2 + "\"linux\": \"natives - linux\"";
                    }
                    if (versionText.libraries[i].natives.osx != null)
                    {
                        if (str2 != null)
                        {
                            str2 = str2 + ",";
                        }
                        str2 = str2 + "\"osx\": \"natives - osx\"";
                    }
                    if (versionText.libraries[i].natives.windows != null)
                    {
                        if (str2 != null)
                        {
                            str2 = str2 + ",";
                        }
                        str2 = str2 + "\"windows\": \"" + versionText.libraries[i].natives.windows + "\"";
                    }
                    str = str + str2 + "}},";
                }
                else
                {
                    str = str + "},";
                }
                if (i == (versionText.libraries.ToArray().Length - 1))
                {
                    char[] chArray1 = str.ToCharArray();
                    chArray1[chArray1.Length - 1] = ']';
                    str = null;
                    foreach (char ch in chArray1)
                    {
                        str = str + ch.ToString();
                    }
                }
            }
            return(str + ",\"mainClass\": \"" + versionText.mainClass + "\"");
        }
Esempio n. 9
0
        internal async Task <string> liteloaderJsonY(ForgeY.Root versionText, string type, string patch, string version, string filename, string javaPath)
        {
            string[] textArray1 = new string[] { "\"assetIndex\": {\"id\": \"", versionText.assetIndex.id, "\",\"size\":", versionText.assetIndex.size, ",\"url\": \"", versionText.assetIndex.url, "\"},\"assets\": \"", versionText.assets, "\",\"downloads\": {\"client\": {\"url\":\"", versionText.downloads.client.url, "\"}},\"id\": \"", versionText.id, "\",\"libraries\": [" };
            string   str        = string.Concat(textArray1);

            ForgeY.Artifact  artifact  = new ForgeY.Artifact();
            ForgeY.Downloads downloads = new ForgeY.Downloads();
            var DO = Minecraft.DownloadOptifine(version, filename);

            ForgeY.LibrariesItem item = new ForgeY.LibrariesItem();
            item.name          = DO.name;
            artifact.url       = DO.Url;
            downloads.artifact = artifact;
            item.downloads     = downloads;
            versionText.libraries.Add(item);
            ForgeDownload forgeDownload = new ForgeDownload(new MCDownload[] { new MCDownload()
                                                                               {
                                                                                   Url = DO.Url, path = DO.path
                                                                               } });

            forgeDownload.StartDownload();
            await Task.Run(() =>
            {
                while (!forgeDownload.GetEndDownload())
                {
                    Thread.Sleep(2000);
                }
            });

            if (forgeDownload.error != 0)
            {
                throw new SquareMinecraftLauncherException("安装失败,下载optifine失败");
            }
            Unzip  unzip = new Unzip();
            string err;

            unzip.UnZipFile(DO.path, System.Directory.GetCurrentDirectory() + @"\SquareMinecraftLauncher\OptiFine\", out err);
            if (File.Exists(System.Directory.GetCurrentDirectory() + @"\SquareMinecraftLauncher\OptiFine\launchwrapper-of.txt"))
            {
                string launch = File.ReadAllText(System.Directory.GetCurrentDirectory() + @"\SquareMinecraftLauncher\OptiFine\launchwrapper-of.txt");
                SLC.path(System.Directory.GetCurrentDirectory() + @"\.minecraft\libraries\optifine\launchwrapper-of\" + launch);
                File.Copy(System.Directory.GetCurrentDirectory() + @"\SquareMinecraftLauncher\OptiFine\launchwrapper-of-" + launch + ".jar", System.Directory.GetCurrentDirectory() + @"\.minecraft\libraries\optifine\launchwrapper-of\" + launch + @"\launchwrapper-of-" + launch + ".jar");
                ForgeY.LibrariesItem item2      = new ForgeY.LibrariesItem();
                ForgeY.Artifact      artifact2  = new ForgeY.Artifact();
                ForgeY.Downloads     downloads2 = new ForgeY.Downloads();
                item2.name          = "optifine:launchwrapper-of:" + launch;
                artifact2.url       = DO.Url;
                downloads2.artifact = artifact2;
                item2.downloads     = downloads2;
                versionText.libraries.Add(item2);
            }
            else
            {
                if (!tools.ForgeExist(version))
                {
                    ForgeY.LibrariesItem item2      = new ForgeY.LibrariesItem();
                    ForgeY.Artifact      artifact2  = new ForgeY.Artifact();
                    ForgeY.Downloads     downloads2 = new ForgeY.Downloads();
                    item2.name          = "net.minecraft:launchwrapper:1.12";
                    artifact2.url       = "http://files.minecraftforge.net/maven/";
                    downloads2.artifact = artifact2;
                    item2.downloads     = downloads2;
                    versionText.libraries.Add(item2);
                }
            }
            if (File.Exists(System.Directory.GetCurrentDirectory() + @"\SquareMinecraftLauncher\OptiFine\optifine\Patcher.class"))
            {
                SLC.path(System.Directory.GetCurrentDirectory() + @"\.minecraft\libraries\optifine\OptiFine\" + DO.name.Split(':')[2]);
                string  arg     = "-cp \"" + DO.path + "\" optifine.Patcher " + System.Directory.GetCurrentDirectory() + @"\.minecraft\versions\" + version + @"\" + version + ".jar " + DO.path + " " + System.Directory.GetCurrentDirectory() + @"\.minecraft\libraries\optifine\OptiFine\" + DO.name.Split(':')[2] + @"\" + DO.name.Split(':')[2] + ".jar";
                Process process = Process.Start(javaPath, arg);
                await Task.Run(() => { process.WaitForExit(); });

                process.Close();
            }
            else
            {
                throw new SquareMinecraftLauncherException("安装失败,OptiFine存在问题");
            }
            SLC.DelPathOrFile(System.Directory.GetCurrentDirectory() + @"\SquareMinecraftLauncher\OptiFine\");
            for (int i = 0; versionText.libraries.ToArray().Length > i; i++)
            {
                str = str + "{\"name\":\"" + versionText.libraries[i].name + "\",";
                if ((versionText.libraries[i].downloads == null) || (versionText.libraries[i].downloads.artifact == null))
                {
                    str = str.Substring(0, str.Length - 1);
                }
                else
                {
                    str = str + "\"downloads\":{\"artifact\":{\"url\":\"" + versionText.libraries[i].downloads.artifact.url + "\"}}";
                }
                if (versionText.libraries[i].natives != null)
                {
                    str = str + ",\"natives\": {";
                    string str2 = null;
                    if (versionText.libraries[i].natives.linux != null)
                    {
                        if (str2 != null)
                        {
                            str2 = str2 + ",";
                        }
                        str2 = str2 + "\"linux\": \"natives - linux\"";
                    }
                    if (versionText.libraries[i].natives.osx != null)
                    {
                        if (str2 != null)
                        {
                            str2 = str2 + ",";
                        }
                        str2 = str2 + "\"osx\": \"natives - osx\"";
                    }
                    if (versionText.libraries[i].natives.windows != null)
                    {
                        if (str2 != null)
                        {
                            str2 = str2 + ",";
                        }
                        str2 = str2 + "\"windows\": \"" + versionText.libraries[i].natives.windows + "\"";
                    }
                    str = str + str2 + "}},";
                }
                else
                {
                    str = str + "},";
                }
                if (i == (versionText.libraries.ToArray().Length - 1))
                {
                    char[] chArray1 = str.ToCharArray();
                    chArray1[chArray1.Length - 1] = ']';
                    str = null;
                    foreach (char ch in chArray1)
                    {
                        str = str + ch.ToString();
                    }
                }
            }
            return(str + ",\"mainClass\": \"net.minecraft.launchwrapper.Launch\"");
        }