Ejemplo n.º 1
0
        static void PrintHelpForGroup(Player p, string sort, string modifier,
                                      string type, string category)
        {
            List <Command> cmds = new List <Command>();

            foreach (Command c in Command.allCmds)
            {
                string disabled = Command.GetDisabledReason(c.Enabled);
                if (p.group.CanExecute(c) && disabled == null)
                {
                    if (!c.type.CaselessContains(type) || c.name == null)
                    {
                        continue;
                    }
                    cmds.Add(c);
                }
            }

            if (cmds.Count == 0)
            {
                p.Message("You cannot use any of the " + category + " commands."); return;
            }
            SortCommands(cmds, sort);
            p.Message(category + " commands you may use:");

            type = "Commands " + category;
            if (sort.Length > 0)
            {
                type += " " + sort;
            }
            MultiPageOutput.Output(p, cmds,
                                   (cmd) => CmdHelp.GetColor(cmd) + cmd.name,
                                   type, "commands", modifier, false);
            p.Message("Type %T/Help <command> %Sfor more help on a command.");
        }
Ejemplo n.º 2
0
        static void PrintAllCommands(Player p, string sort, string modifier)
        {
            List <Command> cmds = new List <Command>();

            foreach (Command c in Command.all.commands)
            {
                if (c.name == null)
                {
                    continue;
                }
                cmds.Add(c);
            }

            SortCommands(cmds, sort);
            Player.Message(p, "All commands:");

            string type = "Commands all";

            if (sort.Length > 0)
            {
                type += " " + sort;
            }
            MultiPageOutput.Output(p, cmds,
                                   (cmd) => CmdHelp.GetColor(cmd) + cmd.name,
                                   type, "commands", modifier, false);
            Player.Message(p, "Type %T/Help <command> %Sfor more help on a command.");
        }
Ejemplo n.º 3
0
        static void PrintAllCommands(Player p, string sort, string modifier)
        {
            List <Command> cmds = Command.CopyAll();

            SortCommands(cmds, sort);
            p.Message("All commands:");

            string type = "Commands all";

            if (sort.Length > 0)
            {
                type += " " + sort;
            }
            MultiPageOutput.Output(p, cmds,
                                   (cmd) => CmdHelp.GetColor(cmd) + cmd.name,
                                   type, "commands", modifier, false);
            p.Message("Type &T/Help <command> &Sfor more help on a command.");
        }
Ejemplo n.º 4
0
        static bool PrintCategoryCommands(Player p, string sort, string modifier, string type)
        {
            List <Command> cmds     = new List <Command>();
            string         category = GetCategory(type);
            bool           foundAny = false;

            foreach (Command c in Command.allCmds)
            {
                string disabled = Command.GetDisabledReason(c.Enabled);
                if (!c.type.CaselessEq(category))
                {
                    continue;
                }

                if (disabled == null && p.CanUse(c))
                {
                    cmds.Add(c);
                }
                foundAny = true;
            }
            if (!foundAny)
            {
                return(false);
            }

            if (cmds.Count == 0)
            {
                p.Message("You cannot use any of the " + category + " commands."); return(true);
            }
            SortCommands(cmds, sort);
            p.Message(category.Capitalize() + " commands you may use:");

            type = "Commands " + type;
            if (sort.Length > 0)
            {
                type += " " + sort;
            }
            MultiPageOutput.Output(p, cmds,
                                   (cmd) => CmdHelp.GetColor(cmd) + cmd.name,
                                   type, "commands", modifier, false);

            p.Message("Type &T/Help <command> &Sfor more help on a command.");
            return(true);
        }
Ejemplo n.º 5
0
        static void SearchCommands(Player p, string keyword, string modifier)
        {
            List <string> commands = FilterList(Command.allCmds, keyword, cmd => cmd.name,
                                                null, cmd => CmdHelp.GetColor(cmd) + cmd.name);
            List <string> shortcuts = FilterList(Command.allCmds, keyword, cmd => cmd.shortcut,
                                                 cmd => !String.IsNullOrEmpty(cmd.shortcut),
                                                 cmd => CmdHelp.GetColor(cmd) + cmd.name);

            // Match both names and shortcuts
            foreach (string shortcutCmd in shortcuts)
            {
                if (commands.CaselessContains(shortcutCmd))
                {
                    continue;
                }
                commands.Add(shortcutCmd);
            }

            OutputList(p, keyword, "search commands", "commands", modifier, commands);
        }
Ejemplo n.º 6
0
        static void PrintRankCommands(Player p, string sort, string modifier, Group group, bool own)
        {
            List <Command> cmds = new List <Command>();

            foreach (Command c in Command.allCmds)
            {
                string disabled = Command.GetDisabledReason(c.Enabled);
                if (!group.CanExecute(c) || disabled != null || c.name == null)
                {
                    continue;
                }
                cmds.Add(c);
            }

            if (cmds.Count == 0)
            {
                p.Message("{0} %Scannot use any commands.", group.ColoredName); return;
            }
            SortCommands(cmds, sort);
            if (own)
            {
                p.Message("Available commands:");
            }
            else
            {
                p.Message("Commands available to " + group.ColoredName + " %Srank:");
            }

            string type = "Cmds " + group.Name;

            if (sort.Length > 0)
            {
                type += " " + sort;
            }
            MultiPageOutput.Output(p, cmds,
                                   (cmd) => CmdHelp.GetColor(cmd) + cmd.name,
                                   type, "commands", modifier, false);
            p.Message("Type %T/Help <command> %Sfor more help on a command.");
        }