/** * List all the available MobArena commands for the CommandSender. * * @param sender a player or the console */ private void showHelp(CommandSender sender) { StringBuilder user = new StringBuilder(); StringBuilder admin = new StringBuilder(); for (Command cmd : commands.values()) { CommandInfo info = cmd.getClass().getAnnotation(CommandInfo.class); if (!PermHandler.hasPerm(sender, info.permission())) continue; StringBuilder buffy; if (info.permission().contains("admin")) buffy = admin; else buffy = user; buffy .append("\n") .append(ChatColor.RESET) .append(info.usage()) .append(" ") .append(ChatColor.YELLOW) .append(info.desc()); } if (admin.length() == 0) { Messenger.sendMessage(sender, "Available Commands: " + user.toString()); } else { Messenger.sendMessage(sender, "User Commands: " + user.toString()); Messenger.sendMessage(sender, "Admin Commands: " + admin.toString()); } }
/** * Show the usage and description messages of a command to a player. The usage will only be shown, * if the player has permission for the command. * * @param cmd a Command * @param sender a CommandSender */ private void showUsage(Command cmd, CommandSender sender, boolean prefix) { CommandInfo info = cmd.getClass().getAnnotation(CommandInfo.class); if (!PermHandler.hasPerm(sender, info.permission())) return; sender.sendMessage( (prefix ? "Usage: " : "") + info.usage() + " " + ChatColor.YELLOW + info.desc()); }