public void RegisterSubCommand(PvPBattleCommandInfo info) { if (info != null) { SubCommandHandlers[info.Command] = info; } }
public void RegisterSubCommandAlias(string command, params string[] alias) { if (!IsCommand(command)) { return; } PvPBattleCommandInfo info = SubCommandHandlers[command]; foreach (string cmd in alias) { RegisterSubCommand(cmd, info.Handler, info.Description, info.Usage, info.Access); } }
public void RegisterSubCommand(PvPBattleCommandInfo info) { if (info == null) { return; } if (SubCommandHandlers.ContainsKey(info.Command)) { SubCommandHandlers[info.Command] = info; } else { SubCommandHandlers.Add(info.Command, info); } }
public bool HandleSubCommand(PlayerMobile pm, string speech) { if (pm == null || pm.Deleted || String.IsNullOrWhiteSpace(speech)) { return(false); } speech = speech.Trim(); if (!speech.StartsWith(SubCommandPrefix.ToString(CultureInfo.InvariantCulture))) { return(false); } string command = String.Empty; var args = new string[0]; speech = speech.TrimStart(SubCommandPrefix); var split = speech.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (split.Length > 0) { command = split[0]; args = new string[split.Length - 1]; for (int i = 0; i < args.Length; i++) { args[i] = split[i + 1]; } } if (!IsCommand(command)) { pm.SendMessage("Command not found."); return(true); } PvPBattleCommandInfo info = SubCommandHandlers[command]; if (pm.AccessLevel < info.Access) { pm.SendMessage("You do not have access to that command."); return(true); } if (args.Length > 0 && (args[0] == "?" || Insensitive.Equals(args[0], "help"))) { pm.SendMessage("Usage: {0}{1} {2}", SubCommandPrefix, info.Command, info.Usage); pm.SendMessage(info.Description); return(true); } PvPBattleCommandState state = new PvPBattleCommandState(this, pm, command, args); if (info.Handler.Invoke(state)) { OnCommand(state); return(true); } pm.SendMessage("Usage: {0}{1} {2}", SubCommandPrefix, info.Command, info.Usage); pm.SendMessage(info.Description); return(true); }