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 + "\"");
        }
        public void GetLoaderVersionJson(string loaderVersion, string version, string Idversion)
        {
            var json = web.getHtml("https://maven.fabricmc.net/net/fabricmc/fabric-loader/" + loaderVersion + "/fabric-loader-" + loaderVersion + ".json");

            if (json != null)
            {
                var jo = JsonConvert.DeserializeObject <fabricmcJson.Root>(json);
                foreach (var i in jo.libraries.common)//增加fabicmcLibraries
                {
                    ForgeY.LibrariesItem lib = new ForgeY.LibrariesItem();
                    lib.name = i.name;
                    if (i.url != null)
                    {
                        ForgeY.Downloads downloads = new ForgeY.Downloads();
                        ForgeY.Artifact  Artifact  = new ForgeY.Artifact();
                        downloads.artifact = Artifact;
                        if (i.url == "http://repo.maven.apache.org/maven2/")
                        {
                            i.url = "https://repo.maven.apache.org/maven2/";
                        }
                        Artifact.url  = i.url;
                        lib.downloads = downloads;
                    }
                    libItem.Add(lib);
                }
                /*/增加fabricmc本身/*/
                ForgeY.LibrariesItem lib1 = new ForgeY.LibrariesItem();
                lib1.name = "net.fabricmc:fabric-loader:" + loaderVersion;
                ForgeY.Downloads downloads1 = new ForgeY.Downloads();
                ForgeY.Artifact  Artifact1  = new ForgeY.Artifact();
                downloads1.artifact = Artifact1;
                Artifact1.url       = "https://maven.fabricmc.net/";
                lib1.downloads      = downloads1;
                libItem.Add(lib1);
                ForgeY.LibrariesItem lib2 = new ForgeY.LibrariesItem();
                lib2.name = "net.fabricmc:intermediary:" + Idversion;
                ForgeY.Downloads downloads2 = new ForgeY.Downloads();
                ForgeY.Artifact  Artifact2  = new ForgeY.Artifact();
                downloads2.artifact = Artifact2;
                Artifact2.url       = "https://maven.fabricmc.net/";
                lib2.downloads      = downloads2;
                libItem.Add(lib2);
                /*/结束/*/
                var json1 = SLC.GetFile(System.Directory.GetCurrentDirectory() + @"\.minecraft\versions\" + version + @"\" + version + ".json");
                var jo1   = JsonConvert.DeserializeObject <ForgeY.Root>(json1);
                foreach (var i in jo1.libraries)//增加版本libraries
                {
                    ForgeY.LibrariesItem lib = new ForgeY.LibrariesItem();
                    lib.name      = i.name;
                    lib.downloads = i.downloads;
                    lib.url       = i.url;
                    lib.natives   = i.natives;
                    libItem.Add(lib);
                }
                string mainclass = jo.mainClass.client;  //fabricmcMainClass
                string Arguments = ArgumentsJson(json1); //组成新的Arguments
                Arguments = Arguments.Substring(0, Arguments.Length - 1);
                SLC.wj(System.Directory.GetCurrentDirectory() + @"\.minecraft\versions\" + version + @"\" + version + ".json", new NewJson().newJson(libItem, Arguments, mainclass, jo1));
                return;
            }
            throw new SquareMinecraftLauncherException("访问失败");
        }
示例#3
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 + "\"");
        }
示例#4
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\"");
        }