void snapshot_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { mainForm.statusBar.Value = 0; if (e.Error != null) { MessageBox.Show(e.Error.Message); } byte[] webPage = { }; webPage = e.Result; String lineArray = Encoding.UTF8.GetString(webPage); String[] lines = lineArray.Split(new Char[] { }); int i = 0; bool b = false; while (b != true) { if (lines[i].Contains("assets") & lines[i].Contains("minecraft.jar")) { mainForm.link = lines[i]; mainForm.link = mainForm.link.Substring(6, mainForm.link.Length - 6); // Remove first 6. mainForm.link = mainForm.link.Substring(0, mainForm.link.IndexOf("\"")); String[] mysplit = mainForm.link.Split('/'); mainForm.version = mysplit[3]; b = true; } i++; } Download download = new Download(mainForm); download.downloadAndInstall(); }
void login_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { mainForm.statusBar.Value = 0; if (e.Error != null) { MessageBox.Show(e.Error.Message); } mainForm.result = e.Result; if (mainForm.result.Contains(':')) { mainForm.rememberMe.save(); String[] output = mainForm.result.Split(':'); if (mainForm.mojangAccount) { mainForm.username = output[2]; } mainForm.sessionID = output[3]; mainForm.version = output[0]; if (mainForm.snapshotButton.Checked) { mainForm.path = mainForm.rootPath + "snapshot/.minecraft/bin/"; Environment.SetEnvironmentVariable("APPDATA", mainForm.rootPath + "snapshot/"); if (mainForm.updateButton.Checked == true) { Snapshot snapshot = new Snapshot(mainForm); snapshot.detectSnapshotVersion(); } else { mainForm.launchMinecraft(); } } else if (mainForm.normalButton.Checked) { mainForm.path = mainForm.rootPath + "normal/.minecraft/bin/"; Environment.SetEnvironmentVariable("APPDATA", mainForm.rootPath + "normal/"); if (mainForm.updateButton.Checked == true) { mainForm.link = mainForm.downloadlink + "minecraft.jar"; Download download = new Download(mainForm); download.downloadAndInstall(); } else { mainForm.launchMinecraft(); } } } else if (mainForm.result.Contains("Bad")) { mainForm.statusLabel.Text = "Incorrect username or password."; } else { mainForm.statusLabel.Text = mainForm.result; } }