Solved Good way to make a help command

Discussion in 'Plugin Development' started by MCForger, Mar 1, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    MCForger

    Hello,
    I had a question how I should go about making almost a list command that only has 5 of a type of variable per page. How should I accomplish this? Any help is always helpful!
    So like:
    =====Map (1/4)=====
    - type
    - type
    - type
    - type
    - type
    ==============
    The 1 out of 4 being the current page out of the max pages.

    Hate to bump but I'am puzzled =P

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  2. Offline

    Technius

    Have a string array and loop through the array, checking the current page on each iteration.
     
  3. Offline

    gomeow

    You might look up 'pagination'

    Also, only bump after 12 hours
     
  4. Offline

    Tirelessly

    int page = whatever;
    for(int i = (page*numberPerPage); i < (page * numberPerPage) + numberPerPage; i++){
    player.sendMessage(collection.get(i));
    }
     
  5. Offline

    MCForger

    Alright thank you will try!
    Sorry for bumping right away to. Never have done it before.

    Code:
                        sender.sendMessage("======" + ChatColor.GOLD + "Titles"
                                + ChatColor.WHITE + "======");
                        List<Title> whatTheyHave = new ArrayList<Title>();
                        whatTheyHave.addAll(_plugin.getAPI().getPlayersTitles(
                                (Player) sender));
                        int page = 1;
                        for (int i = (page * 5); i < (page * 5) + 5; i++)
                        {
                            if (i < whatTheyHave.size())
                            {
                                sender.sendMessage(ChatColor.GOLD + "- "
                                        + ChatColor.WHITE
                                        + whatTheyHave.get(i).getColorName());
                            }
                        }
                        sender.sendMessage("================");
    So if there is more then 5 how do you recommend me making it so they can see page 2? Should I make a function that returns a string[] separated every 5? Then when they do a command like /list <number> it gets that page?
    Trying to make it like the essentials rules command. The format

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  6. Offline

    Tirelessly

    Just change the value of the "page" variable to 2.

    EDIT: I did that a bit wrong - instead of adding 5 to the second piece, don't add anything. In the first piece, do -5.
     
  7. Offline

    MCForger

    Okay. I wasn't sure if I should do that or not =P
    Thank you! Solved how to do the rest!
     
Thread Status:
Not open for further replies.

Share This Page