예제 #1
0
        private void createInstance_Button_Click(object sender, EventArgs e)
        {
            var installTypeChooser = new InstallTypeChooser();

            if (installTypeChooser.ShowDialog() == DialogResult.OK)
            {
                var creator = new InstanceCreationWizard();
                creator.BasePath = mcServerPath_TextBox.Text;
                switch (installTypeChooser.SelectionBox.SelectedItem)
                {
                case "Modded":
                    creator.ServerType = ServerType.Modded;
                    creator.Order      = CreatorTabOrder.Modded;
                    creator.ShowDialog();

                    var tupm = creator.ResultValues;
                    MiscTools.SpawnBackgroundWorker(() => handler.CreateInstance(tupm.Item1).WaitForExit(), () => {
                        if (tupm.Item2 != null)
                        {
                            handler.BungeeifyInstance(tupm.Item2, tupm.Item1.InstancesPath);
                        }
                    });
                    break;

                case "Spigot":
                    creator.ServerType = ServerType.Bukkit;
                    creator.Order      = CreatorTabOrder.Spigot;
                    creator.ShowDialog();

                    var tups = creator.ResultValues;
                    MiscTools.SpawnBackgroundWorker(() => handler.CreateInstance(tups.Item1).WaitForExit(),
                                                    () => { if (tups.Item2 != null)
                                                            {
                                                                handler.BungeeifyInstance(tups.Item2, tups.Item1.InstancesPath);
                                                            }
                                                    });
                    break;

                case "Bedrock":
                    creator.ServerType = ServerType.Bedrock;
                    creator.Order      = CreatorTabOrder.Bedrock;
                    creator.ShowDialog();

                    var tupb = creator.ResultValues;
                    handler.CreateInstance(tupb.Item1);
                    break;
                }
            }

            //var creator = new InstanceCreationWizard();
            // creator.Order = new[] { 0, 4, 8, 1, 3 };
            // creator.ShowDialog();
        }
예제 #2
0
        private void modifyInstance_Button_Click(object sender, EventArgs e)
        {
            var modifyTypeChooser = new ModifyTypeChooser();

            if (modifyTypeChooser.ShowDialog() == DialogResult.OK)
            {
                switch (modifyTypeChooser.SelectionBox.SelectedItem)
                {
                case "Modify":
                    /*if (GetAnySelectedNode() != null)
                     * {
                     *  var modifier = new InstanceModifier();
                     *  modifier.Editor = Editor;
                     *  modifier.ManagerHandler = handler;
                     *  modifier.FullDirPath = GetAnySelectedNode().FullPath;
                     *  modifier.Show();
                     * }
                     * else
                     * {
                     *  MessageBox.Show("Select a directory in the idle instances.");
                     * }*/
                    MessageBox.Show("This is pretty broken and useless right now. You should probably just have the drive mounted and use your own text editor and other programs.");
                    break;

                case "Update":
                    if (GetAnySelectedNode() != null)
                    {
                        var  children   = GetAnySelectedNode().Nodes;
                        bool isInstance = false;
                        foreach (TreeNode child in children)
                        {
                            if (child.Text.Equals("launch.sh"))
                            {
                                isInstance = true;
                            }
                        }
                        if (isInstance)
                        {
                            var instpath = GetAnySelectedNode().FullPath;
                            var wizard   = new InstanceCreationWizard();
                            wizard.Order = new[] { CreatorTab.Start, CreatorTab.DownloadLink };
                            wizard.instanceName_TextBox.Text = instpath.Substring(MiscTools.CommonStartsWith(instpath, mcServerPath_TextBox.Text).Length);
                            wizard.BasePath = mcServerPath_TextBox.Text;

                            var chooser = new InstallTypeChooser();
                            if (chooser.ShowDialog() == DialogResult.OK)
                            {
                                switch (chooser.SelectionBox.SelectedItem)
                                {
                                case "Modded":
                                    wizard.ServerType = ServerType.Modded;
                                    break;

                                case "Spigot":
                                    wizard.ServerType = ServerType.Bukkit;
                                    break;

                                case "Bedrock":
                                    wizard.ServerType = ServerType.Bedrock;
                                    break;
                                }
                            }
                            if (wizard.ShowDialog() == DialogResult.OK)
                            {
                                if (wizard.ServerType == ServerType.Modded)
                                {
                                    wizard.ResultValues.Item1.ExcludedFiles = new[] {                                            // TODO: don't hardcode this
                                        "backups",
                                        "journeymap",
                                        "logs",
                                        "schematics",
                                        "world",
                                        "banned-ips.json",
                                        "banned-players.json",
                                        "eula.txt",
                                        "ops.json",
                                        "server.properties",
                                        "usercache.json",
                                        "usernamecache.json",
                                        "whitelist.json",
                                        "mods/aaasponge.jar",
                                        "config/sponge"
                                    }
                                }
                                ;
                                handler.UpdateInstance(wizard.ResultValues.Item1);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Select an instance in the idle instances");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Select an instance in the idle instances");
                    }
                    break;
                }
            }
        }