public static GameCommand GuessCommand(string cmd) { GameCommand command = GetCommand(cmd); if (command == null) { string str = cmd.ToLower(); IDictionaryEnumerator enumerator = m_cmds.GetEnumerator(); while (enumerator.MoveNext()) { GameCommand command2 = enumerator.Value as GameCommand; string key = enumerator.Key as string; if ((command2 != null) && key.ToLower().StartsWith(str)) { return(command2); } } } return(command); }
public static bool HandleCommandNoPlvl(BaseClient client, string cmdLine) { try { string[] pars = ParseCmdLine(cmdLine); GameCommand myCommand = GuessCommand(pars[0]); if (myCommand == null) { return(false); } ExecuteCommand(client, myCommand, pars); } catch (Exception exception) { if (log.IsErrorEnabled) { log.Error("HandleCommandNoPlvl", exception); } } return(true); }
public static bool HandleCommandNoPlvl(BaseClient client, string cmdLine) { try { string[] array = CommandMgr.ParseCmdLine(cmdLine); GameCommand gameCommand = CommandMgr.GuessCommand(array[0]); if (gameCommand == null) { return(false); } CommandMgr.ExecuteCommand(client, gameCommand, array); } catch (Exception exception) { if (CommandMgr.log.IsErrorEnabled) { CommandMgr.log.Error("HandleCommandNoPlvl", exception); } } return(true); }
public static bool HandleCommandNoPlvl(BaseClient client, string cmdLine) { bool result; try { string[] pars = CommandMgr.ParseCmdLine(cmdLine); GameCommand myCommand = CommandMgr.GuessCommand(pars[0]); if (myCommand == null) { result = false; return(result); } CommandMgr.ExecuteCommand(client, myCommand, pars); } catch (Exception e) { CommandMgr.log.Error("HandleCommandNoPlvl", e); } result = true; return(result); }
public static GameCommand GuessCommand(string cmd) { GameCommand gameCommand = CommandMgr.GetCommand(cmd); if (gameCommand != null) { return(gameCommand); } string value = cmd.ToLower(); IDictionaryEnumerator enumerator = CommandMgr.m_cmds.GetEnumerator(); while (enumerator.MoveNext()) { GameCommand gameCommand2 = enumerator.Value as GameCommand; string text = enumerator.Key as string; if (gameCommand2 != null && text.ToLower().StartsWith(value)) { gameCommand = gameCommand2; break; } } return(gameCommand); }
private static bool ExecuteCommand(BaseClient client, GameCommand myCommand, string[] pars) { pars[0] = myCommand.m_cmd; return(myCommand.m_cmdHandler.OnCommand(client, pars)); }
private static bool ExecuteCommand(BaseClient client, GameCommand myCommand, string[] pars) { pars[0] = myCommand.m_cmd; return myCommand.m_cmdHandler.OnCommand(client, pars); }
public static bool LoadCommands() { m_cmds.Clear(); ArrayList asms = new ArrayList(ScriptMgr.Scripts); foreach (Assembly script in asms) { if (log.IsDebugEnabled) log.Debug("ScriptMgr: Searching for commands in " + script.GetName()); // Walk through each type in the assembly foreach (Type type in script.GetTypes()) { // Pick up a class if (type.IsClass != true) continue; if (type.GetInterface("Game.Base.ICommandHandler") == null) continue; try { object[] objs = type.GetCustomAttributes(typeof(CmdAttribute), false); foreach (CmdAttribute attrib in objs) { bool disabled = false; foreach (string str in m_disabledarray) { if (attrib.Cmd.Replace('&', '/') == str) { disabled = true; log.Info("Will not load command " + attrib.Cmd + " as it is disabled in game properties"); break; } } if (disabled) continue; if (m_cmds.ContainsKey(attrib.Cmd)) { log.Info(attrib.Cmd + " from " + script.GetName() + " has been suppressed, a command of that type already exists!"); continue; } if (log.IsDebugEnabled) log.Debug("Load: " + attrib.Cmd + "," + attrib.Description); GameCommand cmd = new GameCommand(); cmd.m_usage = attrib.Usage; cmd.m_cmd = attrib.Cmd; cmd.m_lvl = attrib.Level; cmd.m_desc = attrib.Description; cmd.m_cmdHandler = (ICommandHandler)Activator.CreateInstance(type); m_cmds.Add(attrib.Cmd, cmd); if (attrib.Aliases != null) { foreach (string alias in attrib.Aliases) { m_cmds.Add(alias, cmd); } } } } catch (Exception e) { if (log.IsErrorEnabled) log.Error("LoadCommands", e); } } } log.Info("Loaded " + m_cmds.Count + " commands!"); return true; }
public static bool LoadCommands() { CommandMgr.m_cmds.Clear(); ArrayList arrayList = new ArrayList(ScriptMgr.Scripts); foreach (Assembly assembly in arrayList) { if (CommandMgr.log.IsDebugEnabled) { CommandMgr.log.Debug("ScriptMgr: Searching for commands in " + assembly.GetName()); } Type[] types = assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { Type type = types[i]; if (type.IsClass && type.GetInterface("Game.Base.ICommandHandler") != null) { try { object[] customAttributes = type.GetCustomAttributes(typeof(CmdAttribute), false); object[] array = customAttributes; for (int j = 0; j < array.Length; j++) { CmdAttribute cmdAttribute = (CmdAttribute)array[j]; bool flag = false; string[] disabledarray = CommandMgr.m_disabledarray; for (int k = 0; k < disabledarray.Length; k++) { string b = disabledarray[k]; if (cmdAttribute.Cmd.Replace('&', '/') == b) { flag = true; CommandMgr.log.Info("Will not load command " + cmdAttribute.Cmd + " as it is disabled in game properties"); break; } } if (!flag) { if (CommandMgr.m_cmds.ContainsKey(cmdAttribute.Cmd)) { CommandMgr.log.Info(string.Concat(new object[] { cmdAttribute.Cmd, " from ", assembly.GetName(), " has been suppressed, a command of that type already exists!" })); } else { if (CommandMgr.log.IsDebugEnabled) { CommandMgr.log.Debug("Load: " + cmdAttribute.Cmd + "," + cmdAttribute.Description); } GameCommand gameCommand = new GameCommand(); gameCommand.m_usage = cmdAttribute.Usage; gameCommand.m_cmd = cmdAttribute.Cmd; gameCommand.m_lvl = cmdAttribute.Level; gameCommand.m_desc = cmdAttribute.Description; gameCommand.m_cmdHandler = (ICommandHandler)Activator.CreateInstance(type); CommandMgr.m_cmds.Add(cmdAttribute.Cmd, gameCommand); if (cmdAttribute.Aliases != null) { string[] aliases = cmdAttribute.Aliases; for (int l = 0; l < aliases.Length; l++) { string key = aliases[l]; CommandMgr.m_cmds.Add(key, gameCommand); } } } } } } catch (Exception exception) { if (CommandMgr.log.IsErrorEnabled) { CommandMgr.log.Error("LoadCommands", exception); } } } } } CommandMgr.log.Info("Loaded " + CommandMgr.m_cmds.Count + " commands!"); return(true); }
public static bool LoadCommands() { CommandMgr.m_cmds.Clear(); ArrayList asms = new ArrayList(ScriptMgr.Scripts); foreach (Assembly script in asms) { CommandMgr.log.Debug("ScriptMgr: Searching for commands in " + script.GetName()); Type[] types = script.GetTypes(); for (int i = 0; i < types.Length; i++) { Type type = types[i]; if (type.IsClass) { if (type.GetInterface("Game.Base.ICommandHandler") != null) { try { object[] objs = type.GetCustomAttributes(typeof(CmdAttribute), false); object[] array = objs; for (int j = 0; j < array.Length; j++) { CmdAttribute attrib = (CmdAttribute)array[j]; bool disabled = false; string[] array2 = CommandMgr.m_disabledarray; for (int k = 0; k < array2.Length; k++) { string str = array2[k]; if (attrib.Cmd.Replace('&', '/') == str) { disabled = true; CommandMgr.log.Info("Will not load command " + attrib.Cmd + " as it is disabled in game properties"); break; } } if (!disabled) { if (CommandMgr.m_cmds.ContainsKey(attrib.Cmd)) { CommandMgr.log.Info(string.Concat(new object[] { attrib.Cmd, " from ", script.GetName(), " has been suppressed, a command of that type already exists!" })); } else { CommandMgr.log.Debug("Load: " + attrib.Cmd + "," + attrib.Description); GameCommand cmd = new GameCommand(); cmd.m_usage = attrib.Usage; cmd.m_cmd = attrib.Cmd; cmd.m_lvl = attrib.Level; cmd.m_desc = attrib.Description; cmd.m_cmdHandler = (ICommandHandler)Activator.CreateInstance(type); CommandMgr.m_cmds.Add(attrib.Cmd, cmd); if (attrib.Aliases != null) { array2 = attrib.Aliases; for (int k = 0; k < array2.Length; k++) { string alias = array2[k]; CommandMgr.m_cmds.Add(alias, cmd); } } } } } } catch (Exception e) { CommandMgr.log.Error("LoadCommands", e); } } } } } CommandMgr.log.Info("CommandMger:Loaded " + CommandMgr.m_cmds.Count + " commands!"); return(true); }
public static bool LoadCommands() { m_cmds.Clear(); ArrayList asms = new ArrayList(ScriptMgr.Scripts); foreach (Assembly script in asms) { if (log.IsDebugEnabled) { log.Debug("ScriptMgr: Searching for commands in " + script.GetName()); } // Walk through each type in the assembly foreach (Type type in script.GetTypes()) { // Pick up a class if (type.IsClass != true) { continue; } if (type.GetInterface("Game.Base.ICommandHandler") == null) { continue; } try { object[] objs = type.GetCustomAttributes(typeof(CmdAttribute), false); foreach (CmdAttribute attrib in objs) { bool disabled = false; foreach (string str in m_disabledarray) { if (attrib.Cmd.Replace('&', '/') == str) { disabled = true; log.Info("Will not load command " + attrib.Cmd + " as it is disabled in game properties"); break; } } if (disabled) { continue; } if (m_cmds.ContainsKey(attrib.Cmd)) { log.Info(attrib.Cmd + " from " + script.GetName() + " has been suppressed, a command of that type already exists!"); continue; } if (log.IsDebugEnabled) { log.Debug("Load: " + attrib.Cmd + "," + attrib.Description); } GameCommand cmd = new GameCommand(); cmd.m_usage = attrib.Usage; cmd.m_cmd = attrib.Cmd; cmd.m_lvl = attrib.Level; cmd.m_desc = attrib.Description; cmd.m_cmdHandler = (ICommandHandler)Activator.CreateInstance(type); m_cmds.Add(attrib.Cmd, cmd); if (attrib.Aliases != null) { foreach (string alias in attrib.Aliases) { m_cmds.Add(alias, cmd); } } } } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("LoadCommands", e); } } } } log.Info("Loaded " + m_cmds.Count + " commands!"); return(true); }