Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add listener for buttons to check if they're on the first or last page when pressing directional buttons #1

Closed
iCodeHaven opened this issue Dec 18, 2017 · 2 comments
Assignees

Comments

@iCodeHaven
Copy link

`
backButton.setListener(event -> {
PaginatedGUI menu = (PaginatedGUI) event.getClickedInventory().getHolder();
if(currentPage <= 0) {
event.getWhoClicked().sendMessage(ChatColor.translateAlternateColorCodes('&', "&8\u00bb &fThere are no more previous pages."));
return;
}
menu.previousPage();
event.getWhoClicked().closeInventory();
event.getWhoClicked().openInventory(getInventory());
});

nextButton.setListener(event -> {
PaginatedGUI menu = (PaginatedGUI) event.getClickedInventory().getHolder();
if(currentPage >= getMaxPage()) {
event.getWhoClicked().sendMessage(ChatColor.translateAlternateColorCodes('&', "&8\u00bb &fThere are no more extra pages."));
return;
}
menu.nextPage();
event.getWhoClicked().closeInventory();
event.getWhoClicked().openInventory(getInventory());
});`

You have no checks to see if they're pressing the buttons on the first or last page, I added some for myself

@masterdoctor masterdoctor self-assigned this Dec 18, 2017
@masterdoctor
Copy link
Owner

Thank you

@masterdoctor
Copy link
Owner

Anyone interested customizing the pagination items and messages, please see: https://github.com/masterdoctor/SpigotPaginatedGUI/wiki/Customizing-the-pagination-items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants