MCSharp.Server.ParseInput C# (CSharp) Method

ParseInput() public method

This function parses input from the server console. In reality the server console should handle the wait for input and call a function within the library to parse a specific command.
public ParseInput ( ) : void
return void
        public void ParseInput()
        {
            string cmd;
            string msg;
            string output;
            while (running)
            {
                string input = Console.ReadLine();
                if (input == null)
                    continue;
                cmd = input.Split(' ')[0];
                if (input.Split(' ').Length > 1)
                    msg = input.Substring(input.IndexOf(' ')).Trim();
                else
                    msg = "";
                try
                {
                    switch (cmd)
                    {
                        case "help":
                            output = "Commands that the console can use: \n";
                            try
                            {
                                foreach (Command command in Command.all.All())
                                {
                                    if (command.ConsoleSupport)
                                    {
                                        output += command.Name + ", ";
                                    }

                                }
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.Message);
                            }
                            output = output.Remove(output.Length - 2);
                            Console.WriteLine(output);
                            break;
                        default:
                            Command runCmd = Command.all.Find(cmd);
                            if (runCmd != null)
                            {
                                if (runCmd.ConsoleSupport)
                                {
                                    runCmd.Use(msg);
                                }
                                else
                                {
                                    Console.WriteLine("This command is not supported by the console!");
                                }
                            }
                            else
                            {
                                Console.WriteLine("No such command!");
                            }
                            break;
                    }
                }
                catch (Exception e)
                {
                    Logger.Log(e.Message, LogType.ErrorMessage);
                }
                //Thread.Sleep(10);
            }
        }

Same methods

Server::ParseInput ( string input ) : void