Beispiel #1
0
        public MCDownload MCjsonDownload(string version)
        {
            MCDownload download = new MCDownload();

            if (Tools.DSI == "Minecraft")
            {
                string str = this.web.getHtml("https://launchermeta.mojang.com/mc/game/version_manifest.json");
                if (str != null)
                {
                    foreach (mcweb.VersionsItem item in JsonConvert.DeserializeObject <mcweb.Root>(str).versions)
                    {
                        if (item.id == version)
                        {
                            download.Url = item.url;
                            string[] textArray1 = new string[] { System.Directory.GetCurrentDirectory(), @"\.minecraft\versions\", version, @"\", version, ".json" };
                            download.path = string.Concat(textArray1);
                        }
                    }
                    return(download);
                }
                download.Url = "https://bmclapi2.bangbang93.com/version/" + version + "/json";
                string[] textArray2 = new string[] { System.Directory.GetCurrentDirectory(), @"\.minecraft\versions\", version, @"\", version, ".json" };
                download.path = string.Concat(textArray2);
                return(download);
            }
            download.Url = "https://bmclapi2.bangbang93.com/version/" + version + "/json";
            string[] textArray3 = new string[] { System.Directory.GetCurrentDirectory(), @"\.minecraft\versions\", version, @"\", version, ".json" };
            download.path = string.Concat(textArray3);
            return(download);
        }
Beispiel #2
0
        private static async Task <(VersionManifest[], MCDownload)> InitData(Config cfg, TransformedTarget[] transformedTargets)
        {
            MCDownload downloader = new MCDownload(new CombinedVersionResolver(
                                                       new LocalVersionResolver(),
                                                       new RemoteVersionResolver()
                                                       ));
            await downloader.Init();

            Log.Step("Initialized MCDownload");

            foreach (Target t in cfg.Targets)
            {
                Directory.CreateDirectory("data/profiles/" + t.Profile);
            }

            var manifests =
                await transformedTargets
                .ToAsyncEnumerable()
                .Distinct()
                .SelectAwait(async x =>
                             await downloader.GetRemoteVersion(x.VersionID).GetManifest()).ToArrayAsync();

            Log.Step("Downloaded manifests");

            return(manifests, downloader);
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="LiteloaderVersion"></param>
        /// <returns></returns>
        public MCDownload DownloadLiteloader(string LiteloaderVersion)
        {
            MCDownload download = new MCDownload {
                path = System.Directory.GetCurrentDirectory() + @"\SquareMinecraftLauncherDownload\liteloader-" + LiteloaderVersion + ".jar"
            };

            string[] textArray1 = new string[] { "https://bmclapi2.bangbang93.com/maven/com/mumfrey/liteloader/", LiteloaderVersion, "/liteloader-", LiteloaderVersion, ".jar" };
            download.Url = string.Concat(textArray1);
            return(download);
        }
        private async void DownloadProgress()
        {
            List <downloader> files = new List <downloader>();

            for (int i = 0; i < 10; i++)
            {
                MCDownload download = AssignedDownload();
                if (download != null)
                {
                    downloader fileDownloader = new downloader();
                    fileDownloader.BuildDownload(download.Url, download.path);
                    fileDownloader.StartDownload();
                    files.Add(fileDownloader);
                }
            }
            if (files.Count == 0)
            {
                Progress        = 100;
                DuckEndDownload = download.Length;
                return;
            }
            await Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    int end = 0;
                    for (int i = 0; i < files.Count; i++)
                    {
                        Speed += files[i].intermation.Speed;
                        if (files[i].intermation.StatusId == -1)
                        {
                            error++;
                        }
                        if (files[i].intermation.Progress == 100)
                        {
                            end++;
                        }
                    }

                    if (end >= files.Count)
                    {
                        DuckEndDownload += files.Count;
                        Speed            = 1;
                        Progress        += 100 / (double)(download.Length) * files.Count;
                        DownloadProgress();//递归

                        return;
                    }
                    Thread.Sleep(200);
                }
            });
        }
 private void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         MCDownload ms = Minecraft.MCjarDownload(listView1.Items[listView1.Items.IndexOf(listView1.FocusedItem)].Text);
         MCDownload ma = Minecraft.MCjsonDownload(listView1.Items[listView1.Items.IndexOf(listView1.FocusedItem)].Text);
         download(ms.path, ms.Url, listView1.Items[listView1.Items.IndexOf(listView1.FocusedItem)].Text + ".jar");
         download(ma.path, ma.Url, listView1.Items[listView1.Items.IndexOf(listView1.FocusedItem)].Text + ".json");
         Console.WriteLine(ms.Url);
         Console.WriteLine(ma.Url);
     }
     catch (ArgumentOutOfRangeException ex)
     {
         MessageBox.Show("请选择需要下载的版本");
     }
 }
Beispiel #6
0
        internal MCDownload ForgeCoreDownload(string version, string ForgeVersion)
        {
            MCDownload download = new MCDownload();
            string     str      = version;

            version = "";
            foreach (AllTheExistingVersion version2 in new Tools().GetAllTheExistingVersion())
            {
                if (version2.version == str)
                {
                    version = version2.IdVersion;
                    break;
                }
            }
            if (version == "")
            {
                throw new SquareMinecraftLauncherException("未找到该版本");
            }
            string str2 = "https://bmclapi2.bangbang93.com";

            if (Tools.DSI == "Minecraft")
            {
                str2 = "https://files.minecraftforge.net";
            }
            char[]   separator  = new char[] { '.' };
            string[] textArray3 = new string[] { System.Directory.GetCurrentDirectory(), @"\SquareMinecraftLauncherDownload\forge-", version, "-", ForgeVersion, "-universal.jar" };
            download.path = string.Concat(textArray3);
            string[] textArray4 = new string[] { str2, "/maven/net/minecraftforge/forge/", version, "-", ForgeVersion, "/forge-", version, "-", ForgeVersion, "-universal.jar" };
            download.Url = string.Concat(textArray4);
            try
            {
                new Download().CreateGetHttpResponse(download.Url);
            }
            catch (Exception)
            {
                string[] textArray1 = new string[] { System.Directory.GetCurrentDirectory(), @"\SquareMinecraftLauncherDownload\forge-", version, "-", ForgeVersion, "-", version, "-universal.jar" };
                download.path = string.Concat(textArray1);
                string[] textArray2 = new string[] { "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/", version, "-", ForgeVersion, "-", version, "/forge-", version, "-", ForgeVersion, "-", version, "-universal.jar" };
                download.Url = string.Concat(textArray2);
            }
            return(download);
        }
 private void Button6_Click(object sender, EventArgs e)
 {
     try
     {
         ForgeList  forge = tools.GetMaxForge(comboBox2.Text);                          //取版本最新forge版本
         MCDownload mc    = Minecraft.ForgeDownload(forge.version, forge.ForgeVersion); //取Forge下载网址
         Console.WriteLine(mc.Url);
         download(mc.path, mc.Url, "Forge");
         intall        = mc.path;
         intallverison = comboBox2.Text;
     }
     catch (SikaDeerLauncher.SikaDeerLauncherException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (ArgumentOutOfRangeException ex)
     {
         MessageBox.Show("请选择需要下载的版本");
     }
 }
Beispiel #8
0
        public MCDownload ForgeDownload(string version, string ForgeVersion)
        {
            MCDownload download = new MCDownload();
            string     str      = version;

            version = "";
            foreach (AllTheExistingVersion version2 in new Tools().GetAllTheExistingVersion())
            {
                if (version2.version == str)
                {
                    version = version2.IdVersion;
                    break;
                }
            }
            if (version == "")
            {
                throw new SquareMinecraftLauncherException("未找到该版本");
            }
            char[] separator = new char[] { '.' };
            if (Convert.ToInt32(version.Split(separator)[1]) < 9)
            {
                return(this.ForgeCoreDownload(str, ForgeVersion));
            }
            string[] textArray1 = new string[] { System.Directory.GetCurrentDirectory(), @"\SquareMinecraftLauncherDownload\forge - ", version, " - ", ForgeVersion, "-installer.jar" };
            download.path = string.Concat(textArray1);
            string[] textArray2 = new string[] { "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/", version, "-", ForgeVersion, "/forge-", version, "-", ForgeVersion, "-installer.jar" };
            download.Url = string.Concat(textArray2);
            try
            {
                new Download().CreateGetHttpResponse(download.Url);
            }
            catch (Exception)
            {
                string[] textArray3 = new string[] { System.Directory.GetCurrentDirectory(), @"\SquareMinecraftLauncherDownload\forge-", version, "-", ForgeVersion, "-", version, "-installer.jar" };
                download.path = string.Concat(textArray3);
                string[] textArray4 = new string[] { "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/", version, "-", ForgeVersion, "-", version, "/forge-", version, "-", ForgeVersion, "-", version, "-installer.jar" };
                download.Url = string.Concat(textArray4);
            }
            return(download);
        }
Beispiel #9
0
        public MCDownload MCjarDownload(string version)
        {
            MCDownload download = new MCDownload();

            if (Tools.DSI == "Minecraft")
            {
                if (Tools.mcV.ToArray().Length == 0)
                {
                    char[]   separator = new char[] { '|' };
                    string[] strArray  = this.SLC.GetFile(@".minecraft\version.Sika").Split(separator);
                    for (int i = 0; i < strArray.Length; i++)
                    {
                        char[]   chArray2  = new char[] { '&' };
                        string[] strArray2 = strArray[i].Split(chArray2);
                        mc       item      = new mc
                        {
                            version = strArray2[0],
                            url     = strArray2[1]
                        };
                        Tools.mcV.Add(item);
                    }
                }
                foreach (mc mc2 in Tools.mcV)
                {
                    if (mc2.version == version)
                    {
                        download.Url = mc2.url;
                        string[] textArray1 = new string[] { System.Directory.GetCurrentDirectory(), @"\.minecraft\versions\", version, @"\", version, ".jar" };
                        download.path = string.Concat(textArray1);
                    }
                }
                return(download);
            }
            download.Url = "https://download.mcbbs.net/version/" + version + "/client";
            string[] textArray2 = new string[] { System.Directory.GetCurrentDirectory(), @"\.minecraft\versions\", version, @"\", version, ".jar" };
            download.path = string.Concat(textArray2);
            return(download);
        }
Beispiel #10
0
        private void Button2_Click(object sender, EventArgs e)
        {
            MCDownload mc = Minecraft.JavaFileDownload();//java下载

            download(mc.path, mc.Url, "java");
        }
        public static async Task WriteScripts(Config cfg, TransformedTarget[] tv, MCDownload downloader)
        {
            foreach (var t in tv)
            {
                MCVersion       v  = downloader.GetRemoteVersion(t.VersionID);
                VersionManifest vm = await v.GetManifest();

                GameArguments combined = new GameArguments(t.From.JVMArguments)
                                         + vm.JavaArguments
                                         //  (vm.LoggingSettings.ContainsKey("client") ? vm.LoggingSettings["client"].GameArgument : new GameArguments("")) +
                                         + new GameArguments("me.basiqueevangelist.launchergenerator.authhelper.MinecraftAuthHelper")
                                         + new GameArguments(vm.MainClass)
                                         + new GameArguments(cfg.Username)
                                         + new GameArguments(t.From.NewGameArguments)
                                         + vm.MinecraftArguments;
                AssetGroupIndex ai = await vm.AssetGroup.GetIndex();

                Dictionary <string, string> variables = new Dictionary <string, string>
                {
                    ["auth_player_name"]  = "@USERNAME",
                    ["version_name"]      = t.VersionID,
                    ["game_directory"]    = ".",
                    ["assets_root"]       = "../../assets",
                    ["game_assets"]       = "../../assets" + (ai.IsVirtual ? "/virtual/" + vm.AssetGroup.ID : ""),
                    ["assets_index_name"] = vm.AssetGroup.ID,
                    ["auth_uuid"]         = "@UUID",
                    ["auth_access_token"] = "@ACCESSTOKEN",
                    ["user_type"]         = "mojang",
                    ["version_type"]      = v.Type.ToString(),
                    ["classpath"]         = Classpath(vm),
                    ["natives_directory"] = "../../versions/" + t.VersionID + "/natives",
                    ["launcher_name"]     = "LauncherGenerator",
                    ["launcher_version"]  = "0.1a",
                    ["path"] = vm.LoggingSettings.ContainsKey("client") ? "../../assets/log_configs/" + ((RemoteFile)vm.LoggingSettings["client"].File).Name : ""
                };
                string[] cargs = combined.Process(variables, Array.Empty <string>());
                string   fname = "data/" + t.From.Name + (Environment.OSVersion.Platform == PlatformID.Win32NT ? ".bat" : ".sh");
                using (FileStream fs = File.Open(fname, System.IO.FileMode.Create, FileAccess.Write, FileShare.Read))
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                        {
                            sw.WriteLine("title Minecraft " + t.VersionID + " launch script");
                            sw.WriteLine("cd %~dp0");
                        }
                        else
                        {
                            sw.WriteLine("#!/bin/sh");
                            sw.WriteLine("printf \"\\033]0;Minecraft " + t.VersionID + " launch script\\007\"");
                            sw.WriteLine("cd $(cd `dirname $0` && pwd)");
                        }
                        sw.WriteLine("cd profiles/" + t.From.Profile);
                        sw.WriteLine(t.From.JavaPath.Replace("\\", "\\\\") + " " + GameArguments.FoldArgs(cargs));
                        // sw.WriteLine("pause");
                    }
                Log.FileNew(fname);
                if (Environment.OSVersion.Platform != PlatformID.Win32NT)
                {
                    UnixFileInfo ufi = new UnixFileInfo(fname);
                    ufi.FileAccessPermissions |= FileAccessPermissions.UserExecute | FileAccessPermissions.GroupRead | FileAccessPermissions.OtherExecute;
                }
            }

            var assembly = typeof(Program).Assembly;

            using (Stream jarIn = assembly.GetManifestResourceStream("LauncherGenerator.MCAuthHelper.jar") ?? throw new NotImplementedException())
                using (FileStream jarOut = File.Open("data/MCAuthHelper.jar", FileMode.Create, FileAccess.Write, FileShare.Delete))
                    await jarIn.CopyToAsync(jarOut);
        }