コード例 #1
0
        /// <summary>
        /// Called when the server is closed
        /// </summary>
        public void ServerExited()
        {
            try
            {
                Invoke((MethodInvoker) delegate
                {
                    ConsoleWindow.SelectionColor = Color.Red;
                    ConsoleWindow.AppendText("\r\nStopped");
                    ConsoleWindow.SelectionColor = Color.White;

                    listBox1.Items.Clear();

                    startToolStripMenuItem.Enable();
                    toolsToolStripMenuItem.Enabled = false;
                    importCommandBlockLanguageFileToolStripMenuItem.Disable();
                    batchImportCommandBlockLanguageFilesToolStripMenuItem.Disable();
                    stopToolStripMenuItem.Disable();
                    restartToolStripMenuItem.Disable();
                    switchToolStripMenuItem.Disable();

                    ServerManager.MinecraftServer.StandardInput.Flush();
                    if (ServerManager.Restart || ServerManager.Switch)
                    {
                        StartServer();
                        ServerManager.Restart = false;
                        ServerManager.Switch  = false;
                    }
                });
            }
            catch
            {
            }
        }
コード例 #2
0
        /// <summary>
        /// Prepares for server start, then starts the server
        /// </summary>
        private void StartServer()
        {
            ChooseFileDialog.Filter = "Minecraft Server Files (*.jar)|*.jar";
            if (ServerManager.Restart || ChooseFileDialog.ShowDialog() == true)
            {
                ConsoleWindow.AppendText("Loading...");
                ConsoleWindow.ScrollToEnd();

                //Server starts here
                ServerManager.StartServer(ChooseFileDialog.FileName, this);
                button.ToolTip = "Run command";
                label.Content  = "No players";
                iconTransition.SelectedIndex = 1;

                toolStrip.Background = (SolidColorBrush)FindResource("PrimaryHueMidBrush");
                button.Background    = (SolidColorBrush)FindResource("PrimaryHueMidBrush");
                button.BorderBrush   = (SolidColorBrush)FindResource("PrimaryHueMidBrush");

                listBox1.Items.Clear();
                serverStart.IsEnabled   = false;
                toolsMenu.IsEnabled     = true;
                toolsImport.IsEnabled   = true;
                toolsBatch.IsEnabled    = true;
                serverStop.IsEnabled    = true;
                serverRestart.IsEnabled = true;
                serverSwitch.IsEnabled  = true;
            }
            ServerManager.Restart = false;
            ServerManager.Switch  = false;
        }
コード例 #3
0
        /// <summary>
        /// Adds text to the ConsoleWindow
        /// </summary>
        public void UpdateText()
        {
            ConsoleWindow.SelectionColor = Color.Cyan;
            string timestring = DateTime.Now.ToString("M/d HH:mm:ss");

            ConsoleWindow.AppendText(string.Format("\r\n[{0}]: {1}", timestring, TextToAdd));
            ConsoleWindow.ScrollToCaret();
            ConsoleWindow.SelectionColor = Color.White;
        }
コード例 #4
0
        /// <summary>
        /// Sends the specified command to the server
        /// </summary>
        /// <param name="command">The exact command text to send</param>
        public void SendCommand(string command)
        {
            ServerManager.MinecraftServer.StandardInput.WriteLine(command);
            ServerManager.MinecraftServer.StandardInput.FlushAsync();
            ConsoleWindow.SelectionColor = Color.Cyan;
            string timestring = DateTime.Now.ToString("M/d HH:mm:ss");

            ConsoleWindow.AppendText(string.Format("\r\n[{0}]: {1}", timestring, command));
            ConsoleWindow.ScrollToCaret();
            ConsoleWindow.SelectionColor = Color.White;
        }
コード例 #5
0
 /// <summary>
 /// Activates when you send a command
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SendCommandButton_Click(object sender, EventArgs e)
 {
     if (CommandInput.Text.Trim() != "" && ServerManager.MinecraftServer != null)
     {
         ServerManager.HistoryIndex = -1;
         ServerManager.MinecraftServer.StandardInput.WriteLine(CommandInput.Text);
         ServerManager.MinecraftServer.StandardInput.FlushAsync();
         ConsoleWindow.SelectionColor = Color.Cyan;
         ServerManager.SentCommandsList.Add(CommandInput.Text);
         string timestring = DateTime.Now.ToString("M/d HH:mm:ss");
         ConsoleWindow.AppendText(string.Format("\r\n[{0}]: {1}", timestring, CommandInput.Text));
         ConsoleWindow.ScrollToCaret();
         ConsoleWindow.SelectionColor = Color.White;
         CommandInput.Text            = "";
     }
 }
コード例 #6
0
        /// <summary>
        /// Prepares for server start, then starts the server
        /// </summary>
        private void StartServer()
        {
            ChooseFileDialog.Filter = "Minecraft Server Files (*.jar)|*.jar";
            if (ServerManager.Restart || ChooseFileDialog.ShowDialog() != DialogResult.Cancel)
            {
                ConsoleWindow.AppendText("Loading...");

                //Server starts here
                ServerManager.StartServer(ChooseFileDialog.FileName, this);
                listBox1.Items.Clear();
                startToolStripMenuItem.Disable();
                toolsToolStripMenuItem.Enabled = true;
                importCommandBlockLanguageFileToolStripMenuItem.Enable();
                batchImportCommandBlockLanguageFilesToolStripMenuItem.Enable();
                stopToolStripMenuItem.Enable();
                restartToolStripMenuItem.Enable();
                switchToolStripMenuItem.Enable();
            }
            ServerManager.Restart = false;
            ServerManager.Switch  = false;
        }
コード例 #7
0
        /// <summary>
        /// Called when error data is recieved from the server
        /// However, most error data is sent through standard output
        /// </summary>
        /// <param name="recievedCommand">The recieved error message</param>
        public void ErrorDataRecieved(string recievedCommand)
        {
            ServerManager.LastRecievedMessage = recievedCommand;

            try
            {
                Invoke((MethodInvoker) delegate
                {
                    if (ServerManager.LastRecievedMessage != null && ServerManager.LastRecievedMessage.Trim() != "")
                    {
                        ConsoleWindow.SelectionColor = Color.Red;
                        string timestring            = DateTime.Now.ToString("M/d HH:mm:ss");
                        ConsoleWindow.AppendText(string.Format("\r\n[{0}]: {1}", timestring, ChatTools.FilterCommand(ServerManager.LastRecievedMessage).Trim()));
                        ConsoleWindow.ScrollToCaret();
                        ConsoleWindow.SelectionColor = Color.White;
                    }
                });
            }
            catch
            {
            }
        }
コード例 #8
0
 private void toolsBatch_Click(object sender, RoutedEventArgs e)
 {
     if (toolsBatch.IsEnabled)
     {
         //Opens a folder dialog and then imports all files in the selected folder
         if (ChooseFolderDialog.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
         {
             int    commandCount = 0;
             string directory    = ChooseFolderDialog.SelectedPath;
             foreach (string file in Directory.GetFiles(directory))
             {
                 if (file.EndsWith(".mccbl"))
                 {
                     string         fileName    = System.IO.Path.GetFileName(file);
                     CBLInterpreter interpreter = new CBLInterpreter(this, fileName, false, "@e[type=ArmorStand,name=" + System.IO.Path.GetFileName(file).Replace(' ', '_').Trim() + "]");
                     ConsoleWindow.AppendText("Importing " + fileName);
                     SendCommand(ChatTools.MultiTellraw("@a", new TellrawColor[] { TellrawColor.gold, TellrawColor.aqua }, new string[] { "Importing ", fileName }));
                     CBLFile importer = interpreter.Interpret(file);
                     if (importer != null && importer.Import(this))
                     {
                         commandCount += importer.Commands.Count;
                     }
                     else
                     {
                         SendCommand(ChatTools.Tellraw("@a", TellrawColor.red, "[ERROR] Import was cancelled or failed for file " + file));
                     }
                 }
             }
             SendCommand(ChatTools.MultiTellraw("@a", new TellrawColor[] { TellrawColor.green, TellrawColor.yellow, TellrawColor.green }, new string[] { "Imported ", commandCount.ToString(), " commands" }));
             ConsoleWindow.AppendText("Successfully imported " + commandCount + " commands");
             SendCommand(ChatTools.Tellraw("@a", TellrawColor.red, "Don't forget to enable the first command block of each section"));
         }
         else
         {
             SendCommand(ChatTools.Tellraw("@a", TellrawColor.red, "[ERROR] Import was cancelled or failed"));
         }
     }
 }
コード例 #9
0
 private void batchImportCommandBlockLanguageFilesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (batchImportCommandBlockLanguageFilesToolStripMenuItem.IsEnabled())
     {
         //Opens a folder dialog and then imports all files in the selected folder
         if (ChooseFolderDialog.ShowDialog() != DialogResult.Cancel)
         {
             string directory = ChooseFolderDialog.SelectedPath;
             foreach (string file in Directory.GetFiles(directory))
             {
                 if (file.EndsWith(".mccbl"))
                 {
                     string         fileName    = Path.GetFileName(file);
                     CBLInterpreter interpreter = new CBLInterpreter(this, fileName, false, "@e[type=ArmorStand,name=" + Path.GetFileName(file).Replace(' ', '_').Trim() + "]");
                     ConsoleWindow.AppendText("Importing " + fileName);
                     SendCommand(ChatTools.MultiTellraw("@a", new TellrawColor[] { TellrawColor.gold, TellrawColor.aqua }, new string[] { "Importing ", fileName }));
                     CBLFile importer = interpreter.Interpret(file);
                     if (importer != null && importer.Import(this))
                     {
                         SendCommand(ChatTools.MultiTellraw("@a", new TellrawColor[] { TellrawColor.green, TellrawColor.yellow, TellrawColor.green }, new string[] { "Successfully imported ", importer.Commands.Count.ToString(), " commands" }));
                         ConsoleWindow.AppendText("Successfully imported " + importer.Commands.Count + " commands");
                         SendCommand(ChatTools.Tellraw("@a", TellrawColor.red, "Don't forget to enable the first Command Block if necessary"));
                     }
                     else
                     {
                         SendCommand(ChatTools.Tellraw("@a", TellrawColor.red, "[ERROR] Import was cancelled or failed for file " + file));
                     }
                 }
             }
         }
         else
         {
             SendCommand(ChatTools.Tellraw("@a", TellrawColor.red, "[ERROR] Import was cancelled or failed"));
         }
     }
 }
コード例 #10
0
 /// <summary>
 /// Imports a MCCBL file
 /// </summary>
 /// <param name="reimport">Whether or not to reimport the last import</param>
 /// <param name="selector">Selector at which to import</param>
 private void ImportFile(bool reimport = false, string selector = null)
 {
     if (!reimport)
     {
         //Opens a file dialog and then imports the selected file
         ChooseFileDialog.Filter = "CommandBlock Language Files (*.mccbl)|*.mccbl";
         if (ChooseFileDialog.ShowDialog() == true)
         {
             CBLInterpreter interpreter = new CBLInterpreter(this, ChooseFileDialog.SafeFileName);
             ConsoleWindow.AppendText("Importing " + ChooseFileDialog.SafeFileName);
             SendCommand(ChatTools.MultiTellraw("@a", new TellrawColor[] { TellrawColor.gold, TellrawColor.aqua }, new string[] { "Importing ", ChooseFileDialog.SafeFileName }));
             //SendCommand("say §6Importing §b§l" + ChooseFileDialog.SafeFileName);
             CBLFile importer = interpreter.Interpret(ChooseFileDialog.FileName);
             if (importer != null && importer.Import(this))
             {
                 SendCommand(ChatTools.MultiTellraw("@a", new TellrawColor[] { TellrawColor.green, TellrawColor.yellow, TellrawColor.green }, new string[] { "Imported ", importer.Commands.Count.ToString(), " commands" }));
                 ConsoleWindow.AppendText("Imported " + importer.Commands.Count + " commands");
                 SendCommand(ChatTools.Tellraw("@a", TellrawColor.red, "Don't forget to enable the first command block"));
                 //SendCommand("say §aSuccessfully §aimported §e§l" + importer.Commands.Count + " §acommands");
                 //SendCommand("say §c§l§nDon't §c§l§nforget §cto §cenable §cthe §cfirst §cCommand §cBlock §cif §cnecessary");
             }
             else
             {
                 SendCommand(ChatTools.Tellraw("@a", TellrawColor.red, "Import was cancelled or failed"));
             }
         }
         else
         {
             SendCommand(ChatTools.Tellraw("@a", TellrawColor.red, "Import was cancelled or failed"));
         }
     }
     else
     {
         //Reimports the previously imported commands
         if (ChooseFileDialog.SafeFileName.EndsWith(".mccbl"))
         {
             CBLInterpreter interpreter = new CBLInterpreter(this, ChooseFileDialog.SafeFileName, false, selector ?? Settings.Default.LastSelector);
             ConsoleWindow.AppendText("Reimporting " + ChooseFileDialog.SafeFileName);
             SendCommand(ChatTools.MultiTellraw("@a", new TellrawColor[] { TellrawColor.gold, TellrawColor.aqua }, new string[] { "Reimporting ", ChooseFileDialog.SafeFileName }));
             //SendCommand("say §6Reimporting §b§l" + ChooseFileDialog.SafeFileName);
             CBLFile importer = interpreter.Interpret(ChooseFileDialog.FileName);
             if (importer != null && importer.Import(this))
             {
                 ConsoleWindow.AppendText("Imported " + importer.Commands.Count + " commands");
                 SendCommand(ChatTools.MultiTellraw("@a", new TellrawColor[] { TellrawColor.green, TellrawColor.yellow, TellrawColor.green }, new string[] { "Imported ", importer.Commands.Count.ToString(), " commands" }));
                 SendCommand(ChatTools.Tellraw("@a", TellrawColor.red, "Don't forget to enable the first command block"));
                 //SendCommand("say §aSuccessfully §areimported §e§l" + importer.Commands.Count + " §acommands");
                 //SendCommand("say §c§l§nDon't §c§l§nforget §cto §cenable §cthe §cfirst §cCommand §cBlock §cif §cnecessary");
             }
             else
             {
                 SendCommand(ChatTools.Tellraw("@a", TellrawColor.red, "Reimport was cancelled or failed"));
             }
         }
         else
         {
             SendCommand(ChatTools.MultiTellraw("@a", new TellrawColor[] { TellrawColor.red, TellrawColor.aqua, TellrawColor.red }, new string[] { "Reimporting ", ChooseFileDialog.SafeFileName, " failed" }));
             //SendCommand("say §cReimporting §b§l" + ChooseFileDialog.SafeFileName + " §cFailed!");
         }
     }
 }
コード例 #11
0
        /// <summary>
        /// Called when most status messages are recieved from the server
        /// </summary>
        /// <param name="recievedMessage">The recieved message</param>
        public void OutputDataRecieved(string recievedMessage)
        {
            ServerManager.LastRecievedMessage = recievedMessage;

            try
            {
                Invoke((MethodInvoker) delegate
                {
                    //Checks if message is not blank or null
                    if (ServerManager.LastRecievedMessage != null && ServerManager.LastRecievedMessage.Trim() != "")
                    {
                        //Checks for players logging in so text can be yellow
                        if (ServerManager.LastRecievedMessage.ContainsAny(new string[] { "logged in with entity id", "UUID of player", "left the game", "lost connection:", "joined the game" }))
                        {
                            ConsoleWindow.SelectionColor = Color.Yellow;
                            if (ServerManager.LastRecievedMessage.Contains("logged in with entity id"))
                            {
                                string timeString = DateTime.Now.ToString("M/d HH:mm:ss");
                                ServerManager.ChatHistory.Add(ChatTools.FilterCommand(string.Format("\r\n[{0}]: {1}", timeString, ChatTools.FilterCommand(ServerManager.LastRecievedMessage))));

                                string player = ChatTools.FilterCommand(ServerManager.LastRecievedMessage).Split('[')[0].Trim();
                                ServerManager.LoggedInPlayers.Add(player);
                                listBox1.Items.Add(player);

                                if (File.Exists(ServerManager.MinecraftServer.StartInfo.WorkingDirectory + "\\motd.mccbl"))
                                {
                                    SendCommand(ChatTools.Tellraw("@a[score_motd_min=1]", TellrawColor.white, "Recent Chat History:"));
                                    for (int i = 11; i > 0; i--)
                                    {
                                        try
                                        {
                                            SendCommand(ChatTools.Tellraw("@a[score_motd_min=1]", TellrawColor.white, ServerManager.ChatHistory[ServerManager.ChatHistory.Count - i].Replace(Environment.NewLine, "")));
                                        }
                                        catch (ArgumentOutOfRangeException)
                                        {
                                        }
                                    }
                                    SendCommand(ChatTools.Tellraw("@a[score_motd_min=1]", TellrawColor.white, "--------------------"));
                                    CBLFile motdFile = new CBLInterpreter(this, "MOTD").Interpret(ServerManager.MinecraftServer.StartInfo.WorkingDirectory + "\\motd.mccbl");
                                    motdFile.Execute(player, "");
                                }
                            }
                            else if (ServerManager.LastRecievedMessage.Contains("lost connection"))
                            {
                                string timeString = DateTime.Now.ToString("M/d HH:mm:ss");
                                ServerManager.ChatHistory.Add(ChatTools.FilterCommand(string.Format("\r\n[{0}]: {1}", timeString, ChatTools.FilterCommand(ServerManager.LastRecievedMessage).Trim())));

                                string player = ChatTools.FilterCommand(ServerManager.LastRecievedMessage).Split(new string[] { "lost connection" }, StringSplitOptions.None)[0].Trim();
                                ServerManager.LoggedInPlayers.Remove(player);
                                listBox1.Items.Remove(player);
                            }
                        }
                        //Checks for events that make green text
                        else if (ServerManager.LastRecievedMessage.ContainsAny(new string[] { "Done (", "Starting minecraft server", "Starting Minecraft server", "has just earned the achievement" }))
                        {
                            ConsoleWindow.SelectionColor = Color.Lime;
                        }
                        //Checks for errors sent through the standard output and colors them red
                        else if (ServerManager.LastRecievedMessage.ContainsAny(new string[] { "moved too quickly!", "with pending removal and duplicate UUID", "change, or is the server overloaded?", "is sending move packets too frequently", "exception was", "FAILED TO BIND", "perhaps a server", "stopping server", "Stopping server" }))
                        {
                            ConsoleWindow.SelectionColor = Color.Red;
                        }
                        //Finds FATAL errors sent through standard output and colors them orange
                        else if (ServerManager.LastRecievedMessage.ContainsAny(new string[] { "A single server tick took", "server will forcibly shutdown", "This crash report has" }))
                        {
                            ConsoleWindow.SelectionColor = Color.Orange;
                        }
                        //Checks if the message is a chat message
                        if (ChatTools.FilterCommand(ServerManager.LastRecievedMessage).StartsWith("<"))
                        {
                            string timeString = DateTime.Now.ToString("M/d HH:mm:ss");
                            //Adds the message to the chat history
                            ServerManager.ChatHistory.Add(ChatTools.FilterCommand(string.Format("\r\n[{0}]: {1}", timeString, ChatTools.FilterCommand(ServerManager.LastRecievedMessage).Trim())));
                            ConsoleWindow.SelectionColor = Color.Violet;
                            //Finds the actual chat message portion of the incoming message
                            string chatMessage = ChatTools.FilterCommand(ServerManager.LastRecievedMessage).Split('>')[1];
                            //Gets the username of the player who sent the message
                            string user = ChatTools.FilterUsername(ChatTools.FilterCommand(ServerManager.LastRecievedMessage));
                            //Checks for custom commands
                            bool wasUserMade = false;
                            if (chatMessage.TrimStart().StartsWith("@!"))
                            {
                                Dictionary <string, CBLFile> CustomCommands = new Dictionary <string, CBLFile>();

                                string cmdDir = ServerManager.MinecraftServer.StartInfo.WorkingDirectory + "\\commands";
                                if (Directory.Exists(cmdDir))
                                {
                                    foreach (string file in Directory.GetFileSystemEntries(ServerManager.MinecraftServer.StartInfo.WorkingDirectory + "\\commands"))
                                    {
                                        CustomCommands.Add(Path.GetFileName(file), new CBLInterpreter(this, Path.GetFileName(file)).Interpret(file));
                                    }
                                }

                                //Checks if the message matches a user-made custom command
                                if (CustomCommands.ContainsKey(chatMessage.TrimStart().Split(' ')[0] + ".mccbl"))
                                {
                                    wasUserMade = true;

                                    CustomCommands[chatMessage.TrimStart().Split(' ')[0] + ".mccbl"].Execute(user, chatMessage.TrimStart().Split(' ').Length > 1 ? string.Join(" ", chatMessage.TrimStart().Split(' ').Skip(1)) : "");
                                }

                                //Checks for premade custom commands
                                //TODO: Allow turning these commands on or off
                                //TODO: Specify which players can use these commands

                                //Imports a MCCBL from the given link or file path at the player who used the command
                                //Examples:
                                //@!import http://example.com/mccblfile.mccbl
                                //@!import http://example.com/textfile.txt
                                //@!import C:\Users\TestUser\Documents\localfile.mccbl
                                if (chatMessage.TrimStart().StartsWith("@!import "))
                                {
                                    string link = chatMessage.CommandArgument("@!import");
                                    CBLInterpreter interpreter   = new CBLInterpreter(this, link, true, ChatTools.FilterUsername(ChatTools.FilterCommand(ServerManager.LastRecievedMessage)));
                                    ConsoleWindow.SelectionColor = Color.Cyan;
                                    ConsoleWindow.AppendText("\nRemote Importing from " + link);
                                    SendCommand(ChatTools.MultiTellraw("@a", new TellrawColor[] { TellrawColor.gold, TellrawColor.aqua, TellrawColor.gold, TellrawColor.aqua }, new string[] { "Remote Importing from ", link, " as ", "Remote Import.mccbl" }));
                                    //SendCommand("say §6Remote §6Importing §6from §b§l" + link + " §6as §b§lRemote §b§lImport.mccbl");
                                    CBLFile importer = interpreter.Interpret(link);
                                    if (importer != null && importer.Import(this))
                                    {
                                        ConsoleWindow.SelectionColor = Color.Cyan;
                                        ConsoleWindow.AppendText("\nSuccessfully imported " + interpreter.commands.Count + " commands");
                                        SendCommand(ChatTools.MultiTellraw("@a", new TellrawColor[] { TellrawColor.green, TellrawColor.yellow, TellrawColor.green }, new string[] { "Successfully imported ", interpreter.commands.Count.ToString(), " commands" }));
                                        //SendCommand("say §aSuccessfully §aimported §e§l" + interpreter.commands.Count + " §acommands");
                                        SendCommand(ChatTools.Tellraw("@a", TellrawColor.red, "Don't forget to enable the first Command Block if necessary"));
                                        //SendCommand("say §c§l§nDon't §c§l§nforget §cto §cenable §cthe §cfirst §cCommand §cBlock §cif §cnecessary");
                                    }
                                }
                                //Reimports the last locally imported file at the given selector
                                //Does not reimport from a link
                                //Example:
                                //@!reimport @p
                                else if (chatMessage.TrimStart().StartsWith("@!reimport "))
                                {
                                    ImportFile(true, chatMessage.CommandArgument("@!reimport"));
                                }
                                //Restarts the server by sending the 'stop' command and then restarting it
                                //Example:
                                //@!restart
                                else if (chatMessage.TrimStart().StartsWith("@!restart"))
                                {
                                    ServerManager.Restart = true;
                                    Close();
                                }
                                //Adds the specefied text to a text file stored in the server's root directory
                                //Useful to store coordinates or ideas
                                //Example:
                                //@!addline This text will be put in a text file
                                //@!addtext This text will be put in a text file
                                else if (chatMessage.TrimStart().StartsWith("@!addtext ") || chatMessage.TrimStart().StartsWith("@!addline "))
                                {
                                    string textLine = chatMessage.CommandArgument("@!addtext");
                                    timeString      = DateTime.Now.ToString("M/d HH:mm:ss");
                                    try
                                    {
                                        File.AppendAllLines(Path.GetDirectoryName(ServerManager.ServerJarPath) + ServerManager.MinecraftServer.StartInfo.WorkingDirectory.Split('\\')[ServerManager.MinecraftServer.StartInfo.WorkingDirectory.Split('\\').Length - 1] + ".txt", new string[] { "[" + timeString + "] <" + user + "> " + textLine });
                                        SendCommand(ChatTools.Tellraw(user, TellrawColor.green, "Added line to file successfully"));
                                    }
                                    catch (Exception ex)
                                    {
                                        SendCommand(ChatTools.Tellraw(user, TellrawColor.red, "Failed to add line to file" + ex.Message));
                                    }
                                }
                                //Views a page (5 lines) from the text file
                                //Example:
                                //@!viewtext 3
                                //@!viewtext
                                else if (chatMessage.TrimStart().StartsWith("@!viewtext "))
                                {
                                    try
                                    {
                                        int page = 0;
                                        if (!int.TryParse(chatMessage.CommandArgument("@!viewtext"), out page))
                                        {
                                            page = 1;
                                        }
                                        string[] fileLines = File.ReadAllLines(Path.GetDirectoryName(ServerManager.ServerJarPath) + ServerManager.MinecraftServer.StartInfo.WorkingDirectory.Split('\\')[ServerManager.MinecraftServer.StartInfo.WorkingDirectory.Split('\\').Length - 1] + ".txt");
                                        SendCommand(ChatTools.Tellraw(user, TellrawColor.aqua, "Page " + page + "/" + Math.Ceiling(fileLines.Length / 5f)));
                                        for (int i = 5 * page - 5; i < 5 * page; i++)
                                        {
                                            try
                                            {
                                                SendCommand(ChatTools.Tellraw(user, TellrawColor.aqua, i + 1 + ": " + fileLines[i]));
                                            }
                                            catch
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        SendCommand(ChatTools.Tellraw(user, TellrawColor.red, "Failed to read file: " + ex.Message));
                                    }
                                }
                                //Deletes the specefied line from the text file
                                //Example:
                                //@!delline 2
                                else if (chatMessage.TrimStart().StartsWith("@!delline "))
                                {
                                    try
                                    {
                                        int line                = Convert.ToInt32(chatMessage.CommandArgument("@!delline")) - 1;
                                        string path             = Path.GetDirectoryName(ServerManager.ServerJarPath) + ServerManager.MinecraftServer.StartInfo.WorkingDirectory.Split('\\')[ServerManager.MinecraftServer.StartInfo.WorkingDirectory.Split('\\').Length - 1] + ".txt";
                                        List <string> fileLines = File.ReadAllLines(path).ToList();
                                        fileLines.RemoveAt(line);
                                        File.WriteAllLines(path, fileLines);
                                        SendCommand(ChatTools.Tellraw(user, TellrawColor.green, "Successfully deleted line " + line));
                                    }
                                    catch (Exception ex)
                                    {
                                        SendCommand(ChatTools.Tellraw(user, TellrawColor.red, "Failed to delete line: " + ex.Message));
                                    }
                                }
                                //Shows all commands, their syntax, and their description
                                //TODO: Allow user-made commands to have a help message
                                //Example:
                                //@!help
                                //TODO: @!help import
                                else if (chatMessage.TrimStart().StartsWith("@!help"))
                                {
                                    SendCommand(ChatTools.Tellraw(user, TellrawColor.yellow, "@!import [link|filepath]: Imports a remote MCCBL File"));
                                    SendCommand(ChatTools.Tellraw(user, TellrawColor.yellow, "@!reimport [selector]: Reimports last locally imported file (no links)"));
                                    SendCommand(ChatTools.Tellraw(user, TellrawColor.yellow, "@!restart: Restarts the server"));
                                    SendCommand(ChatTools.Tellraw(user, TellrawColor.yellow, "@!addtext | @!addline [text]: Adds a line of text to the server text file"));
                                    SendCommand(ChatTools.Tellraw(user, TellrawColor.yellow, "@!viewtext [page]: Shows a page from the server text file"));
                                    SendCommand(ChatTools.Tellraw(user, TellrawColor.yellow, "@!delline [line number]: Deletes a line of text from the server text file"));

                                    foreach (CBLFile customCommand in CustomCommands.Values)
                                    {
                                        string helpText = customCommand.Properties.ContainsKey("HELP") ? customCommand.Properties["HELP"] : "No help text found";
                                        string syntax   = customCommand.Properties.ContainsKey("SYNTAX") ? customCommand.Properties["SYNTAX"] : "";
                                        SendCommand(ChatTools.Tellraw(user, TellrawColor.yellow, customCommand.FileName.Replace(".mccbl", "") + " " + syntax + ": " + helpText));
                                    }
                                }
                                //If no command was found, tell user it doesn't exist
                                else if (!wasUserMade)
                                {
                                    SendCommand(ChatTools.Tellraw(user, TellrawColor.red, "[ERROR] Unknown Command or Bad Syntax, Type @!help for help"));
                                }
                            }

                            //Add chat messages to server console window
                            ConsoleWindow.SelectionColor = Color.Violet;
                            string timestringa           = DateTime.Now.ToString("M/d HH:mm:ss");
                            ConsoleWindow.AppendText(string.Format("\r\n[{0}]: <{2}> {1}", timestringa, chatMessage.Trim(), ChatTools.FilterUsername(ChatTools.FilterCommand(ServerManager.LastRecievedMessage))));
                            ConsoleWindow.ScrollToCaret();
                            ConsoleWindow.SelectionColor = Color.White;
                            return;
                        }
                        //Add other messages to server console window
                        string timestring = DateTime.Now.ToString("M/d HH:mm:ss");
                        ConsoleWindow.AppendText(string.Format("\r\n[{0}]: {1}", timestring, ChatTools.FilterCommand(ServerManager.LastRecievedMessage).Trim()));
                        ConsoleWindow.ScrollToCaret();
                        ConsoleWindow.SelectionColor = Color.White;
                    }
                });
            }
            catch
            {
            }
        }