Class PaginationMenu.Builder
java.lang.Object
me.tayebyassine.homestead.gui.PaginationMenu.Builder
- Enclosing class:
PaginationMenu
-
Method Summary
Modifier and TypeMethodDescriptionactionButton(int index, org.bukkit.inventory.ItemStack item, BiConsumer<org.bukkit.entity.Player, org.bukkit.event.inventory.InventoryClickEvent> callback) Adds an action button to the bottom row of the menu.build()Builds thePaginationMenu.Fills empty header and footer slots with the default empty-slot item.fillEmptySlots(org.bukkit.inventory.ItemStack filler) Fills empty header and footer slots with the given filler item.goBack(BiConsumer<org.bukkit.entity.Player, org.bukkit.event.inventory.InventoryClickEvent> callback) Sets the callback invoked when the go-back button (slot 0) is clicked.Sets the items to display across all pages.itemsPerPage(int n) Sets the number of items displayed per page.nextPageItem(org.bukkit.inventory.ItemStack item) Sets the item displayed for the next-page button.onClick(BiConsumer<org.bukkit.entity.Player, PaginationMenu.ClickContext> callback) Sets the callback invoked when a content item is clicked.Sets a handler invoked after the inventory is created, before it is shown.prevPageItem(org.bukkit.inventory.ItemStack item) Sets the item displayed for the previous-page button.
-
Method Details
-
nextPageItem
Sets the item displayed for the next-page button.- Parameters:
item- the next-page item- Returns:
- this builder
-
prevPageItem
Sets the item displayed for the previous-page button.- Parameters:
item- the previous-page item- Returns:
- this builder
-
items
Sets the items to display across all pages.- Parameters:
items- the content items- Returns:
- this builder
-
goBack
public PaginationMenu.Builder goBack(BiConsumer<org.bukkit.entity.Player, org.bukkit.event.inventory.InventoryClickEvent> callback) Sets the callback invoked when the go-back button (slot 0) is clicked.- Parameters:
callback- the go-back callback- Returns:
- this builder
-
onClick
public PaginationMenu.Builder onClick(BiConsumer<org.bukkit.entity.Player, PaginationMenu.ClickContext> callback) Sets the callback invoked when a content item is clicked.- Parameters:
callback- the click callback- Returns:
- this builder
-
itemsPerPage
Sets the number of items displayed per page.- Parameters:
n- items per page (defaults to content area size)- Returns:
- this builder
-
onOpen
Sets a handler invoked after the inventory is created, before it is shown.- Parameters:
handler- the open handler- Returns:
- this builder
-
fillEmptySlots
Fills empty header and footer slots with the given filler item.- Parameters:
filler- the filler item- Returns:
- this builder
-
fillEmptySlots
Fills empty header and footer slots with the default empty-slot item.- Returns:
- this builder
-
actionButton
public PaginationMenu.Builder actionButton(int index, org.bukkit.inventory.ItemStack item, BiConsumer<org.bukkit.entity.Player, org.bukkit.event.inventory.InventoryClickEvent> callback) Adds an action button to the bottom row of the menu.- Parameters:
index- the button index (0, 1, or 2)item- the item to displaycallback- the click callback (may be null)- Returns:
- this builder
-
build
Builds thePaginationMenu. Next-page and previous-page items must be set.- Returns:
- the built PaginationMenu
- Throws:
IllegalStateException- if next-page or previous-page items are not set
-