Ejemplo n.º 1
0
        static void PromptCopySettings()
        {
            var existingServers = MinecraftServerSetup.GetExistingServerInstances().ToList();

            if (existingServers.Count() > 0)
            {
                var agree = PromptYesNo("Some servers already exist on this machine, would you like to import any data or settings from any of them?");

                if (agree)
                {
                    PromptKeepSettingsAll(existingServers);
                }
                else
                {
                    if (MinecraftServerSetup.ServerExists(options.ServerName))
                    {
                        PromptServerExists();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        static string GetLocalServerVersion()
        {
            // Check if there's already a copy of this jar in the folder
            var jar = new FileInfo(Path.Combine(options.ServerName, options.GetServerJarName()));

            if (jar.Exists)
            {
                return(jar.FullName);
            }

            var servers = MinecraftServerSetup.GetExistingServerInstances();

            foreach (var s in servers)
            {
                jar = s.GetFiles().FirstOrDefault(f => f.Name.Contains(options.GetServerJarName()));
                if (jar != null)
                {
                    return(jar.FullName);
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        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);
        }