Class PaginatedModal
java.lang.Object
io.rhythmknights.coreapi.component.modal.BaseModal
io.rhythmknights.coreapi.component.modal.PaginatedModal
- All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder
- Direct Known Subclasses:
ScrollingModal
Modal that allows you to have multiple pages
-
Constructor Summary
ConstructorsConstructorDescriptionPaginatedModal(@NotNull ModalContainer modalContainer, int pageSize, @NotNull Set<InteractionModifier> interactionModifiers) PaginatedModal(@NotNull ModalContainer modalContainer, @NotNull PaginationRegion paginationRegion, @NotNull Set<InteractionModifier> interactionModifiers) Constructor with pagination region -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds anModalItemto the next available slot in the page areavoidOverriddenBaseModal.addItem(ModalItem...)to add the items to the page insteadvoidvoidclearPageItems(boolean update) Clears all previously added page itemsGets an immutableMapwith all the current pages itemsintGets the current page numberintGets the next page numberGets an immutableListwith all the page items added to the modalintGets the number of pages the modal hasGets the pagination region if one is setintGets the previous page numberbooleannext()Goes to the next pagevoidopen(@NotNull org.bukkit.entity.HumanEntity player) OverridesBaseModal.open(HumanEntity)to use the paginated populator insteadvoidopen(@NotNull org.bukkit.entity.HumanEntity player, int openPage) Specific open method for the Paginated modal UsespopulatePage()booleanprevious()Goes to the previous page if possiblevoidremovePageItem(@NotNull ModalItem item) Removes a givenModalItemfrom the page.voidremovePageItem(@NotNull org.bukkit.inventory.ItemStack item) Removes a givenItemStackfrom the page.setDynamicTitle(@NotNull String baseTitle) Sets a dynamic title that updates with paginationvoidsetPageNum(int pageNum) Sets the page numbersetPageSize(int pageSize) Sets the page sizesetPaginationRegion(@NotNull PaginationRegion paginationRegion) Sets the pagination region to use specific slotsvoidupdate()OverriddenBaseModal.update()to use the paginated openvoidupdatePageItem(int row, int col, @NotNull ModalItem item) AlternativeupdatePageItem(int, ModalItem)that uses ROWS and COLUMNS insteadvoidupdatePageItem(int row, int col, @NotNull org.bukkit.inventory.ItemStack itemStack) AlternativeupdatePageItem(int, ItemStack)that uses ROWS and COLUMNS insteadvoidupdatePageItem(int slot, @NotNull ModalItem item) AlternativeupdatePageItem(int, ItemStack)that usesModalIteminsteadvoidupdatePageItem(int slot, @NotNull org.bukkit.inventory.ItemStack itemStack) Updates the pageModalItemon the slot in the page Can get the slot fromInventoryClickEvent.getSlot()@NotNull BaseModalupdateTitle(@NotNull net.kyori.adventure.text.Component title) OverridesBaseModal.updateTitle(Component)to use the paginated populator instead Updates the title of the modal This method may cause LAG if used on a loopMethods inherited from class io.rhythmknights.coreapi.component.modal.BaseModal
addItem, addSlotAction, addSlotAction, allInteractionsDisabled, allowsOtherActions, canDropItems, canPlaceItems, canSwapItems, canTakeItems, close, close, disableAllInteractions, disableItemDrop, disableItemPlace, disableItemSwap, disableItemTake, disableOtherActions, enableAllInteractions, enableItemDrop, enableItemPlace, enableItemSwap, enableItemTake, enableOtherActions, getFiller, getInventory, getModalItem, getModalItems, getRows, isUpdating, modalContainer, modalType, removeItem, removeItem, removeItem, removeItem, setCloseModalAction, setDefaultClickAction, setDefaultTopClickAction, setDragAction, setInventory, setItem, setItem, setItem, setOpenModalAction, setOutsideClickAction, setPlayerInventoryAction, setUpdateTitleOnItemClick, setUpdating, shouldUpdateTitleOnItemClick, title, updateItem, updateItem, updateItem, updateItem, updateTitleOnItemClick
-
Constructor Details
-
PaginatedModal
public PaginatedModal(@NotNull @NotNull ModalContainer modalContainer, int pageSize, @NotNull @NotNull Set<InteractionModifier> interactionModifiers) -
PaginatedModal
public PaginatedModal(@NotNull @NotNull ModalContainer modalContainer, @NotNull @NotNull PaginationRegion paginationRegion, @NotNull @NotNull Set<InteractionModifier> interactionModifiers) Constructor with pagination region- Parameters:
modalContainer- Modal containerpaginationRegion- Region for pagination itemsinteractionModifiers- Interaction modifiers
-
-
Method Details
-
setPageSize
Sets the page size- Parameters:
pageSize- The new page size- Returns:
- The modal for easier use when declaring, works like a builder
-
setPaginationRegion
Sets the pagination region to use specific slots- Parameters:
paginationRegion- Region defining which slots to use for pagination- Returns:
- The modal
-
getPaginationRegion
Gets the pagination region if one is set- Returns:
- Optional containing the pagination region, or empty if none set
-
setDynamicTitle
Sets a dynamic title that updates with pagination- Parameters:
baseTitle- Base title text- Returns:
- The modal
-
addItem
Adds anModalItemto the next available slot in the page area- Parameters:
item- TheModalItemto add to the page
-
addItem
OverriddenBaseModal.addItem(ModalItem...)to add the items to the page instead -
update
public void update()OverriddenBaseModal.update()to use the paginated open -
updatePageItem
public void updatePageItem(int slot, @NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) Updates the pageModalItemon the slot in the page Can get the slot fromInventoryClickEvent.getSlot()- Parameters:
slot- The slot of the item to updateitemStack- The newItemStack
-
updatePageItem
public void updatePageItem(int row, int col, @NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) AlternativeupdatePageItem(int, ItemStack)that uses ROWS and COLUMNS instead- Parameters:
row- The row of the slotcol- The columns of the slotitemStack- The newItemStack
-
updatePageItem
AlternativeupdatePageItem(int, ItemStack)that usesModalIteminstead- Parameters:
slot- The slot of the item to updateitem- The new ItemStack
-
updatePageItem
AlternativeupdatePageItem(int, ModalItem)that uses ROWS and COLUMNS instead- Parameters:
row- The row of the slotcol- The columns of the slotitem- The newModalItem
-
removePageItem
Removes a givenModalItemfrom the page.- Parameters:
item- TheModalItemto remove.
-
removePageItem
public void removePageItem(@NotNull @NotNull org.bukkit.inventory.ItemStack item) Removes a givenItemStackfrom the page.- Parameters:
item- TheItemStackto remove.
-
open
public void open(@NotNull @NotNull org.bukkit.entity.HumanEntity player) OverridesBaseModal.open(HumanEntity)to use the paginated populator instead -
open
public void open(@NotNull @NotNull org.bukkit.entity.HumanEntity player, int openPage) Specific open method for the Paginated modal UsespopulatePage()- Parameters:
player- TheHumanEntityto open it toopenPage- The specific page to open at
-
updateTitle
@NotNull public @NotNull BaseModal updateTitle(@NotNull @NotNull net.kyori.adventure.text.Component title) OverridesBaseModal.updateTitle(Component)to use the paginated populator instead Updates the title of the modal This method may cause LAG if used on a loop- Overrides:
updateTitlein classBaseModal- Parameters:
title- The title to set- Returns:
- The modal for easier use when declaring, works like a builder
-
getCurrentPageItems
Gets an immutableMapwith all the current pages items- Returns:
- The
Mapwith all thecurrentPage
-
getPageItems
Gets an immutableListwith all the page items added to the modal- Returns:
- The
Listwith all thepageItems
-
getCurrentPageNum
public int getCurrentPageNum()Gets the current page number- Returns:
- The current page number
-
getNextPageNum
public int getNextPageNum()Gets the next page number- Returns:
- The next page number or
pageNumif no next is present
-
getPrevPageNum
public int getPrevPageNum()Gets the previous page number- Returns:
- The previous page number or
pageNumif no previous is present
-
next
public boolean next()Goes to the next page- Returns:
- False if there is no next page.
-
previous
public boolean previous()Goes to the previous page if possible- Returns:
- False if there is no previous page.
-
getPagesNum
public int getPagesNum()Gets the number of pages the modal has- Returns:
- The pages number
-
clearPageItems
public void clearPageItems(boolean update) Clears all previously added page items -
clearPageItems
public void clearPageItems() -
setPageNum
public void setPageNum(int pageNum) Sets the page number- Parameters:
pageNum- Sets the current page to be the specified number
-