Exemplo n.º 1
0
        /// <summary>
        /// Executes a player command.
        /// </summary>
        /// <param name="sender">The player to execute the command</param>
        /// <param name="command">The command to execute</param>
        public static void Execute(Player sender, string command)
        {
            string[]          split = command.Split('\n');
            PlayerCommandInfo pci   = new PlayerCommandInfo();

            pci.Sender      = sender;
            pci.CommandName = split[0].ToLower();
            pci.Arguments   = new List <string>();
            for (int i = 1; i < split.Length; i++)
            {
                pci.Arguments.Add(split[i]);
            }
            pci.Command = GetCommand(pci.CommandName);
            StringBuilder rawargs = new StringBuilder();

            for (int i = 0; i < pci.Arguments.Count; i++)
            {
                rawargs.Append("\"" + pci.Arguments[i] + "\" ");
            }
            pci.RawArguments = rawargs.ToString();
            SysConsole.Output(OutputType.INFO, "Player " + sender.Username + " executes command: /" + pci.CommandName + " " + pci.RawArguments);
            if (pci.Command == null)
            {
                // sender.SendMessage("Unknown command :(");
                sender.SendMessage("^1Unknown command '^5" + pci.CommandName + "^r^1'.");
                SysConsole.Output(OutputType.INFO, " > Denied: Unknown");
            }
            else
            {
                if (!sender.HasPermission("commands." + pci.CommandName))
                {
                    sender.SendMessage("^1You do not have permission to use this command.");
                    SysConsole.Output(OutputType.INFO, " > Denied: No permissions");
                }
                SysConsole.Output(OutputType.INFO, " > Accepted: running");
                pci.Command.Execute(pci);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Runs the command.
 /// </summary>
 public abstract void Execute(PlayerCommandInfo info);