Ejemplo n.º 1
0
        public void TakeCommand(string command)
        {
            String[] commandArray = Regex.Matches(command, @"[\""].+?[\""]|[^ ]+")
                                    .Cast <Match>()
                                    .Select(m => m.Value)
                                    .ToArray();
            NitroxCommand selectedCommand = commands.Where(c => c.Name.ToLower() == commandArray[0].ToLower()).FirstOrDefault();

            if (selectedCommand != null)
            {
                selectedCommand.Execute(client, commandArray.Skip(1).ToArray());
            }
        }
Ejemplo n.º 2
0
        public void TakeCommand(string command)
        {
            String[] commandArray = Regex.Matches(command, @"[\""].+?[\""]|[^ ]+")
                                    .Cast <Match>()
                                    .Select(m => m.Value)
                                    .ToArray();
            NitroxCommand selectedCommand = commands.Where(c => c.Name.ToLower() == commandArray[0].ToLower()).FirstOrDefault();

            if (selectedCommand != null)
            {
                try
                {
                    selectedCommand.Execute(client, commandArray.Skip(1).ToArray());
                }
                catch (InvalidArgumentException e)
                {
                    Console.WriteLine(e.Message + ": " + selectedCommand.Syntax);
                }
                catch (NotEnoughArgumentsException e)
                {
                    Console.WriteLine($"This command takes {e.ArgCount} arguments: " + selectedCommand.Syntax);
                }
            }
        }
Ejemplo n.º 3
0
 public void RegisterCommand(NitroxCommand command)
 {
     commands.Add(command);
 }