static bool CheckJava() { string javaVer = ""; if (!JavaInfo.TryGetJavaVersion(out javaVer)) { Console.WriteLine("You do not currently have Java installed. Please install java, close this window, then try again!"); Console.WriteLine("The Java website should open in a few seconds..."); Thread.Sleep(3000); JavaInfo.OpenDownloadPage(); return(PromptYesNo("Do you believe this message is in error?")); } return(true); }
static void Main(string[] args) { bool agree = false; DisplayGreeting(); CheckOrCreateIPUtil(); if (!CheckJava()) { return; } if (JavaInfo.CheckOrCreatePathEnvVar() == JavaInfo.Result.Warning) { agree = PromptYesNo("The version of Java currently set for your account's Path Environment Variable", " is not the newest version available on your system!", "Would you like to update the Path Environment Variable?"); if (agree) { JavaInfo.ForceUpdatePathEnvVar(); } } options = MinecraftServerSetup.SetupOptions.Empty; PromptServerName(); PromptServerVersion(); PromptServerSeed(); DisplayNewScreen(); PromptCopySettings(); var setup = new MinecraftServerSetup(options); setup.StartSetup(); setup.ScheduleDownloadServerJar(); var asyncErrors = WaitAsyncProgress(setup.BeginFileTransactions(), "Making settings backups and loading server JAR"); if (asyncErrors.Count() > 0) { ReportErrors(asyncErrors); Console.WriteLine("\n[ERROR]: Critical errors have occurred. The setup process is unable to continue..."); Console.ReadLine(); return; } setup.ScheduleCleanupDirectory(); asyncErrors = WaitAsyncProgress(setup.BeginFileTransactions(), "Cleaning directory for setup"); if (asyncErrors.Count() > 0) { ReportErrors(asyncErrors); Console.WriteLine("\n[ERROR]: Critical errors have occurred. The setup process is unable to continue..."); Console.ReadLine(); return; } Console.WriteLine("Executing first-time setup, this may take a minute..."); setup.RunJar(); Console.WriteLine(); DisplayNewScreen(); if (!PromptEula()) { return; } if (!setup.AgreeToEula()) { Console.WriteLine("Unable to agree to the EULA. Please try to edit it by hand"); } setup.ScheduleRestoreBackups(); asyncErrors = WaitAsyncProgress(setup.BeginFileTransactions(), "Restoring saved settings"); ReportErrors(asyncErrors); setup.CreateServerLaunchBin(); setup.AlterServerPropertiesFile(); setup.FinishSetup(); Console.WriteLine("\nDone!"); DisplayNewScreen(); DisplayGetIPInfo(); Console.WriteLine("From now on, just start the Server using LaunchServer.bat in the {0} folder. Enjoy!", options.ServerName); DisplaySeperator(); agree = PromptYesNo("Would you like to start the server now?"); if (agree) { Console.WriteLine("Starting server JAR..."); var process = Process.Start(new ProcessStartInfo() { FileName = "java.exe", WorkingDirectory = Path.GetFullPath(options.ServerName), Arguments = MinecraftServerSetup.GetServerDefaultCommandLineArgs(options.GetServerJarName()), CreateNoWindow = false, UseShellExecute = true }); Console.WriteLine(); } Console.WriteLine("Setup will now close..."); Thread.Sleep(2000); }