public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!Permissions.hasListPermission(sender)) {
      sender.sendMessage(Commands.NO_PERMISSION);
      return true;
    }

    List<Setting> settings = getSortedPlayerSettings(sender);

    int maxPage = (settings.size() - 1) / RESULTS_PER_PAGE + 1;

    int page = 1;
    if (args.length > 0) {
      try {
        page = Integer.parseInt(args[0]);
      } catch (NumberFormatException e) {
        sender.sendMessage(ChatColor.RED + "Unable to parse page number");
        return true;
      }
    }
    page = Math.min(maxPage, Math.max(page, 1)); // constrain page to valid number

    String title = ChatColor.YELLOW + "Settings (Page " + page + " of " + maxPage + ")";
    sender.sendMessage(Commands.formatHeader(title));

    for (int i = RESULTS_PER_PAGE * (page - 1);
        i < RESULTS_PER_PAGE * page && i < settings.size();
        i++) {
      Setting setting = settings.get(i);
      sender.sendMessage(
          ChatColor.YELLOW + setting.getName() + ": " + ChatColor.RESET + setting.getSummary());
    }

    return true;
  }
 public int compare(Setting s1, Setting s2) {
   return s1.getName().compareTo(s2.getName());
 }