Blackixx / BossShopPro

BossShopPro is one of the most player-friendly and multifunctional GUI plugins ever! Say goodbye to all the annoying command- or signshops!
https://www.spigotmc.org/resources/bossshoppro-the-most-powerful-chest-gui-shop-menu-plugin.222/
MIT License
43 stars 63 forks source link

Cannot switch to final page when using a numerical value for the page Reward Type #102

Open Thatsmusic99 opened 3 years ago

Thatsmusic99 commented 3 years ago

When using the page reward type in the pagelayout.yml file, you can never switch to the final page when using the actual page value (e.g. 3, 4) - it switches to the page before that instead.

Files used to reproduce:

menu.yml - https://pastebin.com/2zCv8r25 buy-menu.yml - https://pastebin.com/TSs12q5Q pagelayout.yml - https://pastebin.com/0qJYDhAm

The line of code that I suspect to cause this is the following:

https://github.com/Blackixx/BossShopPro/blob/b8ebbfc58c8849b42152d4acc8d3879abde42b4a/src/main/java/org/black_ixx/bossshop/core/rewards/BSRewardTypeShopPage.java#L74

Rather than using getHighestPage (which would return 3 in this scenario), getDisplayHighestPage should be used in this scenario. I did also test it in my own environment with that method instead, and that fixed the problem. I did test the fix with an erroneous input as well (page 5 when there were only 4 pages) and the plugin responded fine.

If required I can open a pull request for this but this is a tiny fix I'm sure can also be done yourself, I just wanted to highlight the actual cause (since I'm like that, unfortunately for a lot of people ;) ).

Thanks in advance!