Esempio n. 1
0
        internal void ExecuteByPlayer(string cmd, Player player)
        {
            string command = "";

            CommandObject[] args = new CommandObject[0];
            if (cmd.Contains(" "))
            {
                command = cmd.Substring(0, cmd.IndexOf(' '));
                args    = SplitCommand(cmd.Substring(cmd.IndexOf(' ') + 1));
            }
            else
            {
                command = cmd;
            }
            IForgetiveCommand desc = ForgetiveCommandCenter.PreInvoke(command, !player.IsOp);

            if (desc == null)
            {
                player.SendChat("找不到指令或没有权限调用该指令。输入@help查看更多帮助", "Forgetive");
                return;
            }
            desc.invoker = player;
            try
            {
                desc.OnInvoke(args);
            }
            catch
            {
                player.SendChat("<" + command + "> 执行命令时出现内部错误", "Forgetive");
            }
        }
Esempio n. 2
0
        internal CommandObject GetObject(string str)
        {
            for (int i = 0; i < objs.Count; i++)
            {
                if (objs[i].ShowName == str)
                {
                    return(objs[i]);
                }
            }
            CommandObject @object = new CommandObject(typeof(string), str);

            @object.ShowName = str;
            return(@object);
        }
Esempio n. 3
0
        public void SetObject(CommandObject obj)
        {
            bool isDefined = false;

            for (int i = 0; i < objs.Count; i++)
            {
                if (objs[i].ShowName == obj.ShowName)
                {
                    objs[i]   = obj;
                    isDefined = true;
                    break;
                }
            }
            if (!isDefined)
            {
                objs.Add(obj);
            }
        }
Esempio n. 4
0
        internal void Execute(string cmd, bool needRepeatCommand = false)
        {
            string command = "";

            if (needRepeatCommand)
            {
                Logger.WriteLine(LogLevel.Info, "Server> " + cmd);
            }
            CommandObject[] args = new CommandObject[0];
            if (cmd.Contains(" "))
            {
                command = cmd.Substring(0, cmd.IndexOf(' '));
                args    = SplitCommand(cmd.Substring(cmd.IndexOf(' ') + 1));
            }
            else
            {
                command = cmd;
            }
            IForgetiveCommand desc = ForgetiveCommandCenter.PreInvoke(command);

            if (desc == null)
            {
                Logger.WriteLine(LogLevel.Warning, "<{0}> {1}", command, "找不到指令。输入help查看更多帮助");
                return;
            }
            desc.invoker = null;
#if !DEBUG
            try
            {
                desc.OnInvoke(args);
            }
            catch
            {
                Logger.WriteLine(LogLevel.Warning, "<{0}> {1}", command, "执行命令时出现内部错误");
            }
#else
            desc.OnInvoke(args);
#endif
        }