Update Pagination to not pad if only one page exists. #734
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When #639 was merged, some of my pagination broke - see NucleusPowered/Nucleus#158. In this particular case:
Integer.MAX_VALUE
, so that the console can just see the entire MOTD. However, since merging Pad out each page with empty lines, end pages with next page with ... fixes #638 #639, this causes an out of memory error because it's trying to create a huge list. (While I accept I could lower this value, I still want to use the styling that the Pagination service provides without any padding when I do not know how many lines I have.)I think the change provided in #639 is a real usability win, but only when there is more than one page, and this breaks what plugins were expecting before. This PR returns the previous behaviour to one page items, while retaining the new behaviour when there is more than one page.
I have a test plugin that will demonstrate the behaviour: https://gist.github.com/dualspiral/067000c4b1fc80407e79bd51cce151d8
The commands are:
/pg <numberoflines>
, put the word "text" into the pagination list the specified number of times, displaying 20 lines per page./pglg <numberoflines>
, put the phrase "long text text text text text text text text text text text text text text text text text text text text text text text" into the pagination list the specified number of times, 20 lines per page./pgmax <numberoflines>
is the same as/pg
, but can haveInteger.MAX_VALUE
number of lines.I tested with
/pg 1
,/pg 21
,/pglg 10
and/pgmax 25
.