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"); } }
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 }