Ejemplo n.º 1
0
        internal static void Help(Player player, Command cmd)
        {
            string commandName = cmd.Next();

            if (commandName == "commands")
            {
                cdCommands.Handler(player, cmd);
            }
            else if (commandName != null)
            {
                CommandDescriptor descriptor = CommandManager.GetDescriptor(commandName);
                if (descriptor == null)
                {
                    player.Message("Unknown command: \"{0}\"", commandName);
                    return;
                }
                StringBuilder sb = new StringBuilder(Color.Help);
                sb.Append(descriptor.Usage).Append("&N");

                if (descriptor.Aliases != null)
                {
                    sb.Append("Aliases: &H");
                    sb.Append(descriptor.Aliases.JoinToString("&S, &H"));
                    sb.Append("&N");
                }

                if (descriptor.HelpHandler != null)
                {
                    sb.Append(descriptor.HelpHandler(player));
                }
                else if (descriptor.Help != null)
                {
                    sb.Append(descriptor.Help);
                }
                else
                {
                    sb.Append("No help is available for this command.");
                }

                player.MessagePrefixed(HelpPrefix, sb.ToString());

                if (descriptor.Permissions != null && descriptor.Permissions.Length > 0)
                {
                    player.NoAccessMessage(descriptor.Permissions);
                }
            }
            else
            {
                player.Message("To see a list of all commands, write &H/help commands");
                player.Message("To see detailed help for a command, write &H/help CommandName");
                if (player != Player.Console)
                {
                    player.Message("To see your stats, write &H/info");
                }
                player.Message("To list available worlds, write &H/worlds");
                player.Message("To send private messages, write &H@PlayerName Message");
                player.Message("To message all players of a rank, write &H@@Rank Message");
            }
        }