Esempio n. 1
0
        public override void Use(Player p, string message)
        {
            try
            {
                message.ToLower();
                switch (message)
                {
                case "":
                    if (Server.oldHelp)
                    {
                        goto case "old";
                    }
                    else
                    {
                        Player.SendMessage(p, "Use &b/help ranks" + Server.DefaultColor + " for a list of ranks.");
                        Player.SendMessage(p, "Use &b/help build" + Server.DefaultColor + " for a list of building commands.");
                        Player.SendMessage(p, "Use &b/help mod" + Server.DefaultColor + " for a list of moderation commands.");
                        Player.SendMessage(p, "Use &b/help information" + Server.DefaultColor + " for a list of information commands.");
                        Player.SendMessage(p, "Use &b/help other" + Server.DefaultColor + " for a list of other commands.");
                        Player.SendMessage(p, "Use &b/help short" + Server.DefaultColor + " for a list of shortcuts.");
                        Player.SendMessage(p, "Use &b/help old" + Server.DefaultColor + " to view the Old help menu.");
                        Player.SendMessage(p, "Use &b/help [command] or /help [block] " + Server.DefaultColor + "to view more info.");
                    } break;

                case "ranks":
                    message = "";
                    foreach (Group grp in Group.GroupList)
                    {
                        if (grp.name != "nobody")
                        {
                            Player.SendMessage(p, grp.color + grp.name + " - &bCommand limit: " + grp.maxBlocks + " - &cPermission: " + (int)grp.Permission);
                        }
                    }
                    break;

                case "build":
                    message = "";
                    foreach (Command comm in Command.all.commands)
                    {
                        if (p == null || p.group.commands.All().Contains(comm))
                        {
                            if (comm.type.Contains("build"))
                            {
                                message += ", " + getColor(comm.name) + comm.name;
                            }
                        }
                    }

                    if (message == "")
                    {
                        Player.SendMessage(p, "No commands of this type are available to you."); break;
                    }
                    Player.SendMessage(p, "Building commands you may use:");
                    Player.SendMessage(p, message.Remove(0, 2) + ".");
                    break;

                case "mod":
                case "moderation":
                    message = "";
                    foreach (Command comm in Command.all.commands)
                    {
                        if (p == null || p.group.commands.All().Contains(comm))
                        {
                            if (comm.type.Contains("mod"))
                            {
                                message += ", " + getColor(comm.name) + comm.name;
                            }
                        }
                    }

                    if (message == "")
                    {
                        Player.SendMessage(p, "No commands of this type are available to you."); break;
                    }
                    Player.SendMessage(p, "Moderation commands you may use:");
                    Player.SendMessage(p, message.Remove(0, 2) + ".");
                    break;

                case "information":
                    message = "";
                    foreach (Command comm in Command.all.commands)
                    {
                        if (p == null || p.group.commands.All().Contains(comm))
                        {
                            if (comm.type.Contains("info"))
                            {
                                message += ", " + getColor(comm.name) + comm.name;
                            }
                        }
                    }

                    if (message == "")
                    {
                        Player.SendMessage(p, "No commands of this type are available to you."); break;
                    }
                    Player.SendMessage(p, "Information commands you may use:");
                    Player.SendMessage(p, message.Remove(0, 2) + ".");
                    break;

                case "other":
                    message = "";
                    foreach (Command comm in Command.all.commands)
                    {
                        if (p == null || p.group.commands.All().Contains(comm))
                        {
                            if (comm.type.Contains("other"))
                            {
                                message += ", " + getColor(comm.name) + comm.name;
                            }
                        }
                    }

                    if (message == "")
                    {
                        Player.SendMessage(p, "No commands of this type are available to you."); break;
                    }
                    Player.SendMessage(p, "Other commands you may use:");
                    Player.SendMessage(p, message.Remove(0, 2) + ".");
                    break;

                case "short":
                    message = "";
                    foreach (Command comm in Command.all.commands)
                    {
                        if (p == null || p.group.commands.All().Contains(comm))
                        {
                            if (comm.shortcut != "")
                            {
                                message += ", &b" + comm.shortcut + " " + Server.DefaultColor + "[" + comm.name + "]";
                            }
                        }
                    }
                    Player.SendMessage(p, "Available shortcuts:");
                    Player.SendMessage(p, message.Remove(0, 2) + ".");
                    break;

                case "old":
                    string commandsFound = "";
                    foreach (Command comm in Command.all.commands)
                    {
                        if (p == null || p.group.commands.All().Contains(comm))
                        {
                            try { commandsFound += ", " + comm.name; } catch { }
                        }
                    }
                    Player.SendMessage(p, "Available commands:");
                    Player.SendMessage(p, commandsFound.Remove(0, 2));
                    Player.SendMessage(p, "Type \"/help <command>\" for more help.");
                    Player.SendMessage(p, "Type \"/help shortcuts\" for shortcuts.");
                    break;

                default:
                    Command cmd = Command.all.Find(message);
                    if (cmd != null)
                    {
                        cmd.Help(p);
                        string foundRank = Level.PermissionToName(GrpCommands.allowedCommands.Find(grpComm => grpComm.commandName == cmd.name).lowestRank);
                        Player.SendMessage(p, "Rank needed: " + getColor(cmd.name) + foundRank);
                        return;
                    }
                    byte b = Block.Byte(message);
                    if (b != Block.Zero)
                    {
                        Player.SendMessage(p, "Block \"" + message + "\" appears as &b" + Block.Name(Block.Convert(b)));
                        string foundRank = Level.PermissionToName(Block.BlockList.Find(bs => bs.type == b).lowestRank);
                        Player.SendMessage(p, "Rank needed: " + foundRank);
                        return;
                    }
                    Player.SendMessage(p, "Could not find command or block specified.");
                    break;
                }
            }
            catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "An error occured"); }
        }