Exemplo n.º 1
0
        private void changeDSourceO(object sender, EventArgs e)
        {
            string sv = ovs.SelectedItem.ToString() + "-";

            sv = sv.Substring(0, sv.IndexOf("-"));
            string filn = "Optifine_" + sv + "_" + ol.SelectedItem.ToString().Replace("-", "_") + ".jar";

            if (new FileInfo(cd + "\\mods\\" + filn).Length == 0)
            {
                TaskToDo ttd = new TaskToDo();
                ttd.Type = "Download";
                if (filn.Contains("_pre"))
                {
                    filn = "preview_" + filn;
                }
                filn = filn.Replace("Optifine", "OptiFine");
                var htxt = wc.DownloadString("http://optifine.net/adloadx?f=" + filn);
                var req  = htxt.Substring(htxt.IndexOf("downloadx?f="), htxt.IndexOf("\"", htxt.IndexOf("downloadx?f=")) - htxt.IndexOf("downloadx?f="));
                ttd.param = "http://optifine.net/" + req + ";" + cd + "\\mods\\Optifine_" + sv + "_" + ol.SelectedItem.ToString().Replace("-", "_") + ".jar";
                TaskToDo t = new TaskToDo();
                t.Type  = "InstallOptiFine";
                t.param = ol.SelectedItem.ToString().Replace("-", "_") + ";" + ovs.SelectedItem.ToString();
                st      = new ShowTask(new TaskToDo[] { ttd, t });
                st.beginTask();
            }
        }
Exemplo n.º 2
0
        private void button7_Click(object sender, EventArgs e)
        {
            string sv = lvs.SelectedItem.ToString() + "-";

            sv = sv.Substring(0, sv.IndexOf("-"));
            if (ll.SelectedIndex != -1)
            {
                if (jo.Contains("artefacts"))
                {
                    JSONObject stable = jo.getJSONObject("artefacts").getJSONObject("com.mumfrey:liteloader");
                    var        keys   = stable.getKeys();
                    foreach (string key in keys)
                    {
                        if (key == "latest")
                        {
                            continue;
                        }
                        if (stable.getJSONObject(key).getString("version") == ll.SelectedItem.ToString())
                        {
                            TaskToDo t = new TaskToDo();
                            t.Type  = "Download";
                            t.param = String.Format("http://bmclapi2.bangbang93.com/maven/com/mumfrey/liteloader/{0}/liteloader-{1}.jar;" + Application.StartupPath + "\\liteloader-{1}.jar", sv, ll.SelectedItem.ToString());
                            TaskToDo t2 = new TaskToDo();
                            t2.Type            = "InstallLiteLoader";
                            t2.param           = ll.SelectedItem.ToString() + ";" + lvs.SelectedItem.ToString();
                            st                 = new ShowTask(new TaskToDo[] { t, t2 });
                            st.onTaskComplete += new EventHandler(changeDSourcel);
                            st.beginTask();
                        }
                    }
                }
                if (jo.Contains("snapshots"))
                {
                    JSONObject snapshot = jo.getJSONObject("snapshots").getJSONObject("com.mumfrey:liteloader");
                    var        keys     = snapshot.getKeys();
                    foreach (string key in keys)
                    {
                        if (key == "latest")
                        {
                            continue;
                        }
                        if (snapshot.getJSONObject(key).getString("version") == ll.SelectedItem.ToString())
                        {
                            l_snap = true;
                            TaskToDo t = new TaskToDo();
                            t.Type  = "Download";
                            t.param = String.Format("http://dl.liteloader.com/versions/com/mumfrey/liteloader/{0}/liteloader-{0}.jar;" + Application.StartupPath + "\\liteloader-{0}.jar", ll.SelectedItem.ToString());
                            TaskToDo t2 = new TaskToDo();
                            t2.Type            = "InstallLiteLoader";
                            t2.param           = ll.SelectedItem.ToString() + ";" + lvs.SelectedItem.ToString();
                            st                 = new ShowTask(new TaskToDo[] { t, t2 });
                            st.onTaskComplete += new EventHandler(changeDSourcel);
                            st.beginTask();
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 private void button4_Click(object sender, EventArgs e)
 {
     TaskToDo[] t = new TaskToDo[] { new TaskToDo(), new TaskToDo() };
     t[0].Type  = "Download";
     t[0].param = "http://bmclapi2.bangbang93.com/version/" + vers[gl.SelectedIndex].getString("id") + "/client;" + GamePath.Text.Replace(".\\", Application.StartupPath + "\\") + "\\versions\\" + vers[gl.SelectedIndex].getString("id") + "\\" + vers[gl.SelectedIndex].getString("id") + ".jar";
     t[1].Type  = "Download";
     t[1].param = "http://bmclapi2.bangbang93.com/version/" + vers[gl.SelectedIndex].getString("id") + "/json;" + GamePath.Text.Replace(".\\", Application.StartupPath + "\\") + "\\versions\\" + vers[gl.SelectedIndex].getString("id") + "\\" + vers[gl.SelectedIndex].getString("id") + ".json";
     st         = new ShowTask(t);
     st.beginTask();
 }
Exemplo n.º 4
0
        private void button8_Click(object sender, EventArgs e)
        {
            TaskToDo t = new TaskToDo();

            t.param = "http://dl.liteloader.com/versions/versions.json;" + Application.StartupPath + "\\lvl.json";//下载版本列表文件
            t.Type  = "Download";
            ShowTask st = new ShowTask(new TaskToDo[] { t });

            st.onTaskComplete += new EventHandler(loadLvl);
            st.beginTask();
            return;
        }
Exemplo n.º 5
0
        private void button10_Click(object sender, EventArgs e)
        {
            string sv = ovs.SelectedItem.ToString() + "-";

            sv = sv.Substring(0, sv.IndexOf("-"));
            TaskToDo ttd = new TaskToDo();

            ttd.Type           = "Download";
            ttd.param          = "http://bmclapi2.bangbang93.com/optifine/" + sv + ";" + Application.StartupPath + "\\OptiList.json";
            st                 = new ShowTask(new TaskToDo[] { ttd });
            st.onTaskComplete += new EventHandler(loadOvl);
            st.beginTask();
        }
Exemplo n.º 6
0
 private void changeDSourcef(object a, EventArgs b)
 {
     if (new FileInfo(Application.StartupPath + "\\forge-installer_" + fl.SelectedItem.ToString() + ".jar").Length == 0)
     {
         TaskToDo ttd = new TaskToDo();
         ttd.Type  = "Download";
         ttd.param = "http://files.minecraftforge.net/maven/net/minecraftforge/forge/" + VerSel.Text + "-" + fl.SelectedItem.ToString() + "/forge-" + VerSel.Text + "-" + fl.SelectedItem.ToString() + "-installer.jar;" + Application.StartupPath + "\\forge-installer_" + fl.SelectedItem.ToString() + ".jar";
         TaskToDo tti = new TaskToDo();
         tti.Type  = "InstallForge";
         tti.param = Application.StartupPath + "\\forge-installer_" + fl.SelectedItem.ToString() + ".jar;" + VerSel.Text;
         new ShowTask(new TaskToDo[] { ttd, tti }).beginTask();
     }
 }
Exemplo n.º 7
0
        private void button5_Click(object sender, EventArgs e)
        {
            TaskToDo t  = new TaskToDo();
            string   sv = VerSel.SelectedItem.ToString() + "-";

            sv      = sv.Substring(0, sv.IndexOf("-"));
            t.param = "http://bmclapi2.bangbang93.com/forge/minecraft/" + sv + ";" + Application.StartupPath + "\\fvl.json";//下载版本列表文件
            t.Type  = "Download";
            ShowTask st = new ShowTask(new TaskToDo[] { t });

            st.onTaskComplete += new EventHandler(loadFvl);
            st.beginTask();
            return;
        }
Exemplo n.º 8
0
 private void button6_Click(object sender, EventArgs e)
 {
     if (fl.SelectedIndex != -1)
     {
         TaskToDo ttd = new TaskToDo();
         ttd.Type  = "Download";
         ttd.param = "http://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/" + VerSel.Text + "-" + fl.SelectedItem.ToString() + "/forge-" + VerSel.Text + "-" + fl.SelectedItem.ToString() + "-installer.jar;" + Application.StartupPath + "\\forge-installer_" + fl.SelectedItem.ToString() + ".jar";
         TaskToDo tti = new TaskToDo();
         tti.Type  = "InstallForge";
         tti.param = Application.StartupPath + "\\forge-installer_" + fl.SelectedItem.ToString() + ".jar;" + VerSel.Text;
         ShowTask st = new ShowTask(new TaskToDo[] { ttd, tti });
         st.onTaskComplete += new EventHandler(changeDSourcef);
         st.beginTask();
     }
 }
Exemplo n.º 9
0
        private void button9_Click(object sender, EventArgs e)
        {
            string sv = ovs.SelectedItem.ToString() + "-";

            sv = sv.Substring(0, sv.IndexOf("-"));
            if (ol.SelectedIndex != -1)
            {
                TaskToDo ttd = new TaskToDo();
                ttd.Type  = "Download";
                ttd.param = "http://bmclapi2.bangbang93.com/optifine/" + sv + "/" + ol.SelectedItem.ToString().Replace("-", "/") + ";" + cd + "\\mods\\Optifine_" + sv + "_" + ol.SelectedItem.ToString().Replace("-", "_") + ".jar";
                TaskToDo t = new TaskToDo();
                t.Type             = "InstallOptiFine";
                t.param            = ol.SelectedItem.ToString().Replace("-", "_") + ";" + ovs.SelectedItem.ToString();
                st                 = new ShowTask(new TaskToDo[] { ttd, t });
                st.onTaskComplete += new EventHandler(changeDSourceO);
                st.beginTask();
            }
        }
Exemplo n.º 10
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (!File.Exists(Application.StartupPath + "\\version_manifest.json"))
            {
                TaskToDo t = new TaskToDo();
                t.param = "https://launchermeta.mojang.com/mc/game/version_manifest.json;" + Application.StartupPath + "\\version_manifest.json";//下载版本列表文件
                t.Type  = "Download";
                ShowTask st = new ShowTask(new TaskToDo[] { t });
                st.onTaskComplete += new EventHandler(this.button3_Click);
                st.beginTask();
                return;
            }
            jo = new JSONObject(File.ReadAllText(Application.StartupPath + "\\version_manifest.json"));
            File.Delete(Application.StartupPath + "\\version_manifest.json");
            vers = jo.getJSONArray("versions").toJSONObjects();
            gl.Items.Clear();
            foreach (JSONObject ver in vers)
            {
                string showi = ver.getString("id") + " ";
                switch (ver.getString("type"))
                {
                case "release":
                    showi = showi + "正式版";
                    break;

                case "snapshot":
                    showi = showi + "快照版";
                    break;

                case "old_alpha":
                    showi = showi + "Alpha测试版";
                    break;

                case "old_beta":
                    showi = showi + "Beta测试版";
                    break;
                }
                showi = showi + " 发布时间:" + ver.getString("releaseTime");
                gl.Items.Add(showi);
            }
        }
Exemplo n.º 11
0
 private void changeDSourcel(object a, EventArgs b)
 {
     if (new FileInfo(Application.StartupPath + "\\liteloader-" + ll.SelectedItem.ToString() + ".jar").Length == 0)
     {
         string sv = lvs.SelectedItem.ToString() + "-";
         sv = sv.Substring(0, sv.IndexOf("-"));
         TaskToDo ttd = new TaskToDo();
         ttd.Type = "Download";
         if (l_snap)
         {
             ttd.param = String.Format("http://dl.liteloader.com/versions/com/mumfrey/liteloader/{0}/liteloader-{0}.jar;" + Application.StartupPath + "\\liteloader-{0}.jar", ll.SelectedItem.ToString());
         }
         else
         {
             ttd.param = String.Format("http://dl.liteloader.com/versions/com/mumfrey/liteloader/{0}/liteloader-{1}.jar;" + Application.StartupPath + "\\liteloader-{1}.jar", sv, ll.SelectedItem.ToString());
         }
         TaskToDo tti = new TaskToDo();
         tti.Type  = "InstallLiteLoader";
         tti.param = ll.SelectedItem.ToString() + ";" + lvs.SelectedItem.ToString();
         new ShowTask(new TaskToDo[] { ttd, tti }).beginTask();
     }
 }
Exemplo n.º 12
0
        public LauncherReturn LaunchMC(MCLaunchArgs argument, YggDrasilAuth auth, int whatToReturn = 0)
        {
            auth.Login();
            LauncherReturn    lr     = new LauncherReturn();
            JSONObject        jo     = new JSONObject(File.ReadAllText(argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\").Replace("./", Application.StartupPath + "/") + "\\versions\\" + argument.VerName + "\\" + argument.VerName + ".json"));
            String            Libcmd = "";
            List <JSONObject> libs   = new List <JSONObject>();

            libs.AddRange(jo.getJSONArray("libraries").toJSONObjects());
            JSONObject ji  = jo;
            string     jar = argument.VerName;

            #region 处理继承
            if (jo.Contains("inheritsFrom"))
            {
                jar = jo.getString("jar");
                ji  = new JSONObject(File.ReadAllText(argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\").Replace("./", Application.StartupPath + "/") + "\\versions\\" + jo.getString("inheritsFrom") + "\\" + jo.getString("inheritsFrom") + ".json"));
                libs.AddRange(ji.getJSONArray("libraries").toJSONObjects());
                if (ji.Contains("inheritsFrom"))
                {
                    ji = new JSONObject(File.ReadAllText(argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\").Replace("./", Application.StartupPath + "/") + "\\versions\\" + ji.getString("inheritsFrom") + "\\" + ji.getString("inheritsFrom") + ".json"));
                    libs.AddRange(ji.getJSONArray("libraries").toJSONObjects());
                    if (ji.Contains("inheritsFrom"))
                    {
                        ji = new JSONObject(File.ReadAllText(argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\").Replace("./", Application.StartupPath + "/") + "\\versions\\" + ji.getString("inheritsFrom") + "\\" + ji.getString("inheritsFrom") + ".json"));
                        libs.AddRange(ji.getJSONArray("libraries").toJSONObjects());
                    }
                }
            }
            #endregion
            #region 处理库
            String          lnsuffix = "";
            List <TaskToDo> tl       = new List <TaskToDo>();
            foreach (JSONObject libdata in libs)
            {
                String[] libname = libdata.getString("name").Split(":".ToCharArray());
                if (libdata.Contains("natives") && libdata.getJSONObject("natives").Contains("windows"))
                {
                    lnsuffix = "-" + libdata.getJSONObject("natives").getString("windows");
                    lnsuffix = lnsuffix.Replace("${arch}", "32");
                }
                String libpath = argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\") + "\\libraries\\" + libname[0].Replace(".", "\\") + "\\" + libname[1] + "\\" + libname[2] + "\\" + libname[1] + "-" + libname[2] + lnsuffix + ".jar";
                if (Libcmd.Contains(libpath))
                {
                    continue;
                }
                if (File.Exists(libpath))
                {
                    if (libdata.Contains("extract"))
                    {
                        Unzipper.decompress(libpath, argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\") + "\\versions\\" + argument.VerName + "\\" + argument.VerName + "-natives");
                    }
                    else
                    {
                        Libcmd = Libcmd + libpath + ";";
                    }
                }
                else
                {
                    TaskToDo ttd = new TaskToDo();
                    ttd.Type  = "Download";
                    ttd.param = "http://bmclapi2.bangbang93.com/libraries/" + libname[0].Replace(".", "/") + "/" + libname[1] + "/" + libname[2] + "/" + libname[1] + "-" + libname[2] + lnsuffix + ".jar;" + libpath;
                    tl.Add(ttd);
                }
                lnsuffix = "";
            }
            #endregion
            #region 处理资源文件
            bool virt = false;
            if (jo.Contains("assets") && !jo.Contains("assetIndex"))
            {
                var I = new JSONObject();
                I.putString("id", jo.getString("assets"));
                jo.putJSONObject("assetIndex", I);
                ji = jo;
            }
            if (!File.Exists(argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\") + "\\assets\\indexes\\" + ji.getJSONObject("assetIndex").getString("id") + ".json"))
            {
                TaskToDo tt = new TaskToDo();
                tt.Type  = "Download";
                tt.param = ji.getJSONObject("assetIndex").getString("url") + ";" + argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\") + "\\assets\\indexes\\" + ji.getJSONObject("assetIndex").getString("id") + ".json";
                tl.Add(tt);
            }
            else
            {
                JSONObject    joa    = new JSONObject(File.ReadAllText(argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\") + "\\assets\\indexes\\" + ji.getJSONObject("assetIndex").getString("id") + ".json"));
                List <string> files  = joa.getJSONObject("objects").getKeys();
                List <string> hashes = new List <string>();
                virt = joa.Contains("virtual");
                JSONObject job = joa.getJSONObject("objects");
                foreach (string keyf in files)
                {
                    hashes.Add(job.getJSONObject(keyf).getString("hash"));
                }
                bool   lackasset = false;
                string fp, nfp;
                nfp = argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\") + "\\assets\\virtual\\" + ji.getJSONObject("assetIndex").getString("id");
                for (int j = 0; j < files.Count; j++)
                {
                    fp = argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\") + "\\assets\\objects\\" + hashes[j].Substring(0, 2) + "\\" + hashes[j];
                    if (virt)
                    {
                        if (!File.Exists(nfp + "\\" + files[j].Replace("/", "\\")))
                        {
                            lackasset = true;
                            break;
                        }
                    }
                    else
                    {
                        if (!File.Exists(fp))
                        {
                            lackasset = true;
                            break;
                        }
                    }
                }
                if (lackasset)
                {
                    if (MessageBox.Show("资源文件不完整,是否补全?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        for (int j = 0; j < files.Count; j++)
                        {
                            if (virt)
                            {
                                if (!File.Exists(nfp + "\\" + files[j].Replace("/", "\\")))
                                {
                                    TaskToDo to = new TaskToDo();
                                    to.Type  = "Download";
                                    to.param = "http://bmclapi2.bangbang93.com/assets/" + hashes[j].Substring(0, 2) + "/" + hashes[j] + ";" + nfp + "\\" + files[j].Replace("/", "\\");
                                    tl.Add(to);
                                }
                            }
                            else
                            {
                                fp = argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\") + "\\assets\\objects\\" + hashes[j].Substring(0, 2) + "\\" + hashes[j];
                                if (!File.Exists(fp))
                                {
                                    TaskToDo to = new TaskToDo();
                                    to.Type  = "Download";
                                    to.param = "http://bmclapi2.bangbang93.com/assets/" + hashes[j].Substring(0, 2) + "/" + hashes[j] + ";" + fp;
                                    tl.Add(to);
                                }
                            }
                        }
                    }
                }
            }
            #endregion
            if (tl.Count != 0)
            {
                ShowTask st = new ShowTask(tl.ToArray());
                st.yda  = auth;
                st.mcla = argument;
                st.wtr  = whatToReturn;
                if (whatToReturn == 0)
                {
                    st.onTaskCompleteA += new ShowTask.onTaskCompleteEventHandler(LaunchMC);
                }
                st.beginTask();
                lr.rtv = "缺少文件,正在下载。";
                return(lr);
            }
            try
            {
                Directory.Delete(argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\") + "\\versions\\" + argument.VerName + "\\" + argument.VerName + "-natives\\META-INF", true);
            }
            catch (DirectoryNotFoundException ex)
            {
            }
            Libcmd = Libcmd + argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\").Replace("./", Application.StartupPath + "/") + "\\versions\\" + jar + "\\" + jar + ".jar";
            String RunCommand;
            if (auth.Nick != "")
            {
                argument.Nick = auth.Nick;
            }
            String minecraftArguments = "";
            if (jo.Contains("minecraftArguments"))
            {
                minecraftArguments = jo.getString("minecraftArguments");
            }
            else if (jo.Contains("arguments"))
            {
                JSONObject ag   = jo.getJSONObject("arguments");
                var        gmja = ag.getJSONArray("game");
                var        gl   = gmja.length();
                for (int l = 0; l < gl; l++)
                {
                    if (gmja.getString(l).Contains(","))
                    {
                        continue;
                    }
                    minecraftArguments = minecraftArguments + gmja.getString(l).Replace("\n", "").Replace(" ", "") + " ";
                }
                minecraftArguments = minecraftArguments.Substring(0, minecraftArguments.Length - 1);
            }
            minecraftArguments = minecraftArguments.Replace("${auth_player_name}", argument.Nick).Replace("${version_name}", "JuicyLauncher_2").Replace("${game_directory}", "\"" + argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\").Replace("./", Application.StartupPath + "/") + "\"").Replace("${assets_index_name}", ji.getJSONObject("assetIndex").getString("id")).Replace("${auth_uuid}", auth.uuid).Replace("${auth_access_token}", auth.accessToken).Replace("${user_type}", auth.UserType).Replace("${version_type}", "JuicyLauncher_2").Replace("${user_properties}", auth.userProperties.toString()).Replace("${game_assets}", "${assets_root}");

            if (virt == true)
            {
                minecraftArguments = minecraftArguments.Replace("${assets_root}", "\"" + argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\").Replace("./", Application.StartupPath + "/") + "\\assets\\virtual\\" + ji.getJSONObject("assetIndex").getString("id") + "\"");
            }
            else
            {
                minecraftArguments = minecraftArguments.Replace("${assets_root}", "\"" + argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\").Replace("./", Application.StartupPath + "/") + "\\assets\"");
            }
            RunCommand = "-Xmx" + argument.MaxMem.ToString() + "m -Djava.library.path=\"" + argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\").Replace("./", Application.StartupPath + "/") + "\\versions\\" + argument.VerName + "\\" + argument.VerName + "-natives\" " + argument.ExtraJreArgs + " -cp \"" + Libcmd + "\" " + jo.getString("mainClass") + " " + minecraftArguments + " " + argument.ExtraMCArgs;
            Process          p   = new Process();
            ProcessStartInfo psi = new ProcessStartInfo(argument.JrePath, RunCommand);
            psi.WorkingDirectory = argument.CurrentDir.Replace(".\\", Application.StartupPath + "\\").Replace("./", Application.StartupPath + "/");
            psi.UseShellExecute  = false;
            p.StartInfo          = psi;
            if (whatToReturn == 1)
            {
                lr.MCMain = p;
                return(lr);
            }
            p.Start();
            Application.Exit();
            return(lr);
        }