void LaunchGame(string howLaunch) { string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); BLAKE3 blake3 = new BLAKE3(); var hash = blake3.ComputeHash(Encoding.UTF8.GetBytes(tb2.Password)); string passwd = ""; foreach (var b in hash) { passwd += b.ToString("x2"); } if (POST.goPost("http://web1038.craft-host.ru/auth/launcher.php", tb1.Text, passwd, this)) { switch (howLaunch) { case "Default": { dirMain = new DirectoryInfo(appData + "\\" + folder); if (dirMain.Exists) { dirAssets = new DirectoryInfo(appData + "\\" + folder + "\\assets"); dirLibraries = new DirectoryInfo(appData + "\\" + folder + "\\libraries"); dirVersions = new DirectoryInfo(appData + "\\" + folder + "\\versions"); if (dirAssets.Exists && dirLibraries.Exists && dirVersions.Exists) //Only Launch { Launch.StartMinecraft(this); } else if (!dirAssets.Exists && !dirLibraries.Exists && !dirVersions.Exists) //Clean Load { ReloadFilesAndStart(); } else // Something { MessageBox.Show("Отсутствуют некоторые директории игры. Выберите в настройках пункт 'Перекачать клиент' и запустите игру снова."); buttonStart.IsEnabled = true; } } else { DirectoryInfo dirInfo = new DirectoryInfo(appData + "\\" + folder); dirInfo.Create(); ReloadFilesAndStart(); } break; } case "ReloadFiles": { dirAssets = new DirectoryInfo(appData + "\\" + folder + "\\assets"); dirLibraries = new DirectoryInfo(appData + "\\" + folder + "\\libraries"); dirVersions = new DirectoryInfo(appData + "\\" + folder + "\\versions"); if (dirAssets.Exists) { dirAssets.Delete(true); } if (dirLibraries.Exists) { dirLibraries.Delete(true); } if (dirVersions.Exists) { dirVersions.Delete(true); } string serversDat = appData + "\\" + folder + "\\servers.dat"; FileInfo fileInf = new FileInfo(serversDat); if (fileInf.Exists) { fileInf.Delete(); } ReloadFilesAndStart(); break; } } } else { buttonStart.IsEnabled = true; } }
void ReloadFilesAndStart() { Launch.DownloadMinecraftWithStart(downloadLink, this); }