I couldn't find any resource on how to paginate a list and then showing it to the user, so I wrote a method myself. Code:java public void paginate(CommandSender sender, SortedMap<Integer, String> map,int page, int pageLength) { sender.sendMessage(ChatColor.YELLOW + "List: Page (" + String.valueOf(page) + " of " + (((map.size() % pageLength) == 0) ? map.size() / pageLength : (map.size() / pageLength) + 1)); int i = 0, k = 0; page--; for (final Entry<Integer, String> e : map.entrySet()) { k++; if ((((page * pageLength) + i + 1) == k) && (k != ((page * pageLength) + pageLength + 1))) { i++; sender.sendMessage(ChatColor.YELLOW + " - " + e.getValue()); } }} How to use it: Code:java /** Collections.reverseOrder() is optional.* It makes it so the highest numbers get shown first.* Otherwise the lowest number will be shown first.*/SortedMap<Integer, String> map = new TreeMap<Integer, String>(Collections.reverseOrder());map.put(1, "Thing");/** The first parameter is the rank, and the second parameter is the text to be shown.* The SortedMap will automatically sort it.* Add to that map for as many values there are in the list you want to show.*/paginate(sender, map, 1, 5);/** Pass the first parameter as the sender.* The second parameter as the map.* The third as the page number.* The fourth as how long each page should be.*/ I hope this helps you, reply if you have any questions
I actually prefer @zml2008's version as it can be used for multiple listings. Usage is as simple as this: Code:java Collection<Object> collection; //collection of the data that should be idsplayedint page = 4; new PaginatedResult<Object obj>(" Command - Description") { @Override public String format(Object obj) { return obj.toString(); //match each points formating depending on the data that is displayed }}.display(sender, collection, page);