Example #1
0
        private void readyButton_Click(object sender, EventArgs e)
        {
            if (engineSelect.SelectedItem == null)
            {
                Error.Show("ErrorNoEngine");
                return;
            }
            if (this.versionSelect.SelectedItem == null)
            {
                Error.Show("ErrorNoVersion");
                return;
            }
            if (!eulaCheckBox.Checked)
            {
                Error.Show("ErrorNoEula");
                return;
            }
            if (serverName.Text == "")
            {
                Error.Show("ErrorNoServerName");
                return;
            }
            string engine = engineSelect.SelectedItem.ToString(), version = this.versionSelect.SelectedItem.ToString();

            ServerData         = new Data.Server();
            ServerData.name    = serverName.Text;
            ServerData.version = version;
            ServerData.engine  = engine;
            ServerDirectory    = ServerData.GetDirectory();
            if (Directory.Exists(ServerDirectory))
            {
                Error.Show("ErrorServerExists");
                return;
            }
            Directory.CreateDirectory(ServerDirectory);
            string engineDirectory = Main.EnginesDirectory + engine + Path.DirectorySeparatorChar;

            Directory.CreateDirectory(engineDirectory);
            EngineFile = engineDirectory + version + ".jar";
            if (File.Exists(EngineFile))
            {
                DownloadProgressCompleted(null, new AsyncCompletedEventArgs(null, false, null));
            }
            else
            {
                string url = "http://mcservermanager.tk/info/servers/" + engine.ToLower() + "-" + version + ".jar";
                if (engine == "Vanilla")
                {
                    url = "https://s3.amazonaws.com/Minecraft.Download/versions/" + version + "/minecraft_server." + version + ".jar";
                }
                Client = new WebClient();
                Client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);
                Client.DownloadFileCompleted   += new AsyncCompletedEventHandler(DownloadProgressCompleted);
                Client.DownloadFileAsync(new Uri(url), EngineFile);
            }

            this.Enabled = false;
        }
Example #2
0
        private void startButton_Click(object sender, EventArgs e)
        {
            if (process != null && (!process.HasExited))
            {
                return;
            }
            ProcessStartInfo info = new ProcessStartInfo();

            info.CreateNoWindow         = true;
            info.RedirectStandardError  = true;
            info.RedirectStandardOutput = true;
            info.RedirectStandardInput  = true;
            info.ErrorDialog            = false;
            info.UseShellExecute        = false;
            info.WorkingDirectory       = serverData.GetDirectory();
            info.FileName  = GetJavaPath();
            info.Arguments = "-jar ";
            if (serverData.isImported)
            {
                info.Arguments += "\"" + serverData.jarPath + "\"";
            }
            else
            {
                info.Arguments += "server.jar";
            }
            if (serverData.engine == "Vanilla")
            {
                info.Arguments += " nogui";
            }

            process                     = new Process();
            process.StartInfo           = info;
            process.EnableRaisingEvents = true;
            process.OutputDataReceived += new DataReceivedEventHandler(ConsoleOutputHandler);
            process.ErrorDataReceived  += new DataReceivedEventHandler(ConsoleOutputHandler);
            process.Exited             += new EventHandler(ConsoleExited);
            process.Start();
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();
            text.AppendText(tag + String.Format(Utils.Language.GetString("ServerLaunching"), serverData.name) + "\n");
        }
Example #3
0
        private void DownloadProgressCompleted(object sender, AsyncCompletedEventArgs e)
        {
            if (e.Cancelled && File.Exists(ServerDirectory + "server.jar"))
            {
                Directory.Delete(ServerDirectory, true);
                return;
            }
            if (e.Error != null)
            {
                Error.Show("DownloadErrorServer");
                Directory.Delete(ServerDirectory, true);
                File.Delete(EngineFile);
                return;
            }
            ServerData.Save();
            StreamWriter file = File.CreateText(ServerDirectory + "eula.txt");

            file.Write("eula=true");
            file.Close();
            this.readyButton.Text = Language.GetString("DownloadFinished");
            new Computer().FileSystem.CopyFile(EngineFile, ServerData.GetDirectory() + "server.jar", UIOption.AllDialogs);
            this.tabs.mainWindow.serversTree.FullRefresh();
        }
        private void readyButton_Click(object sender, EventArgs e)
        {
            if (engineSelect.SelectedItem == null)
            {
                MessageBox.Show("Wybierz silnik!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (this.versionSelect.SelectedItem == null)
            {
                MessageBox.Show("Wybierz wersję!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!eulaCheckBox.Checked)
            {
                MessageBox.Show("Musisz zaakceptować postanowienia Mojang EULA!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (serverName.Text == "")
            {
                MessageBox.Show("Podaj nazwę serwera!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string engine = engineSelect.SelectedItem.ToString(), version = this.versionSelect.SelectedItem.ToString();
            ServerData = new Data.Server();
            ServerData.name = serverName.Text;
            ServerData.version = version;
            ServerData.engine = engine;
            ServerDirectory = ServerData.GetDirectory();
            if (Directory.Exists(ServerDirectory))
            {
                MessageBox.Show("Serwer o takiej nazwie już istnieje!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Directory.CreateDirectory(ServerDirectory);
            string engineDirectory = Utils.Main.EnginesDirectory + engine + Path.DirectorySeparatorChar;
            Directory.CreateDirectory(engineDirectory);
            EngineFile = engineDirectory + version + ".jar";
            if (File.Exists(EngineFile))
            {
                DownloadProgressCompleted(null, new AsyncCompletedEventArgs(null, false, null));
            }
            else
            {
                string url = "http://mcservermanager.tk/info/servers/" + engine.ToLower() + "-" + Utils.Main.EngineVersions + ".jar";
                if (engine == "Vanilla")
                    url = "https://s3.amazonaws.com/Minecraft.Download/versions/" + version + "/minecraft_server." + version + ".jar";
                Client = new WebClient();
                Client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);
                Client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadProgressCompleted);
                Client.DownloadFileAsync(new Uri(url), EngineFile);
            }

            this.Enabled = false;
        }
        private void readyButton_Click(object sender, EventArgs e)
        {
            if (engineSelect.SelectedItem == null)
            {
                Error.Show("ErrorNoEngine");
                return;
            }
            if (this.versionSelect.SelectedItem == null)
            {
                Error.Show("ErrorNoVersion");
                return;
            }
            if (!eulaCheckBox.Checked)
            {
                Error.Show("ErrorNoEula");
                return;
            }
            if (serverName.Text == "")
            {
                Error.Show("ErrorNoServerName");
                return;
            }
            string engine = engineSelect.SelectedItem.ToString(), version = this.versionSelect.SelectedItem.ToString();
            ServerData = new Data.Server();
            ServerData.name = serverName.Text;
            ServerData.version = version;
            ServerData.engine = engine;
            ServerDirectory = ServerData.GetDirectory();
            if (Directory.Exists(ServerDirectory))
            {
                Error.Show("ErrorServerExists");
                return;
            }
            Directory.CreateDirectory(ServerDirectory);
            string engineDirectory = Main.EnginesDirectory + engine + Path.DirectorySeparatorChar;
            Directory.CreateDirectory(engineDirectory);
            EngineFile = engineDirectory + version + ".jar";
            if (File.Exists(EngineFile))
            {
                DownloadProgressCompleted(null, new AsyncCompletedEventArgs(null, false, null));
            }
            else
            {
                string url = "http://mcservermanager.tk/info/servers/" + engine.ToLower() + "-" + version + ".jar";
                if (engine == "Vanilla")
                    url = "https://s3.amazonaws.com/Minecraft.Download/versions/" + version + "/minecraft_server." + version + ".jar";
                Client = new WebClient();
                Client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);
                Client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadProgressCompleted);
                Client.DownloadFileAsync(new Uri(url), EngineFile);
            }

            this.Enabled = false;
        }