Solved Help Pages - Page line starting point

Discussion in 'Spigot Plugin Development' started by WAS, May 16, 2017.

  1. WAS

    WAS

    Update: I have fixed my initial issue with line counts. However my next issue is how to correctly offset my start point based on the page number. I thought I had an appropriate method but it doesn't seem to work properly. As alas I am just terrible with math.

    Imagine there is a list for example full of X lines. Lets say 40. Now take this code for example it takes a input from the chat, which is the help page.

    Code (Java):
        int startLine = 0;
         if (page > 1 && page < 3) {
           startLine = 19;
         } else if (page >= 3) {
          startLine = 19 * (page-1); //
         }

          for (int i = startLine; i < lines.size(); i++) {
             String line = lines.get(i);
             help.append(line);
            help.append("\n");
             if (i != 0 && i % 19 == 0) { // Here we would need to minus one from 19 as we aren't counting 0.
               if (lines.size() > i)
                 np = true;
               break;
             }
           }
    How can I correctly get the start position of the next page from the page number?
     
    #1 WAS, May 16, 2017
    Last edited: May 16, 2017