Package dev.triumphteam.gui.guis
Class PaginatedGui
java.lang.Object
dev.triumphteam.gui.guis.BaseGui
dev.triumphteam.gui.guis.PaginatedGui
- All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder
- Direct Known Subclasses:
ScrollingGui
GUI that allows you to have multiple pages
-
Constructor Summary
ConstructorsConstructorDescriptionPaginatedGui(int rows, int pageSize, @NotNull String title) Deprecated.PaginatedGui(int rows, int pageSize, @NotNull String title, @NotNull Set<InteractionModifier> interactionModifiers) Main constructor to provide a way to create PaginatedGuiPaginatedGui(int rows, @NotNull String title) Deprecated.In favor ofPaginatedGui(int, int, String, Set)PaginatedGui(@NotNull String title) Deprecated.In favor ofPaginatedGui(int, int, String, Set) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds anGuiItemto the next available slot in the page areavoidOverriddenBaseGui.addItem(GuiItem...)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 GUIintGets the number of pages the GUI hasintGets the previous page numberbooleannext()Goes to the next pagevoidopen(@NotNull org.bukkit.entity.HumanEntity player) OverridesBaseGui.open(HumanEntity)to use the paginated populator insteadvoidopen(@NotNull org.bukkit.entity.HumanEntity player, int openPage) Specific open method for the Paginated GUI UsespopulatePage()booleanprevious()Goes to the previous page if possiblevoidremovePageItem(@NotNull GuiItem item) Removes a givenGuiItemfrom the page.voidremovePageItem(@NotNull org.bukkit.inventory.ItemStack item) Removes a givenItemStackfrom the page.setPageSize(int pageSize) Sets the page sizevoidupdate()OverriddenBaseGui.update()to use the paginated openvoidupdatePageItem(int row, int col, @NotNull GuiItem item) AlternativeupdatePageItem(int, GuiItem)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 GuiItem item) AlternativeupdatePageItem(int, ItemStack)that usesGuiIteminsteadvoidupdatePageItem(int slot, @NotNull org.bukkit.inventory.ItemStack itemStack) Updates the pageGuiItemon the slot in the page Can get the slot fromInventoryClickEvent.getSlot()@NotNull BaseGuiupdateTitle(@NotNull String title) OverridesBaseGui.updateTitle(String)to use the paginated populator instead Updates the title of the GUI This method may cause LAG if used on a loopMethods inherited from class dev.triumphteam.gui.guis.BaseGui
addItem, addSlotAction, addSlotAction, allowsOtherActions, canDropItems, canPlaceItems, canSwapItems, canTakeItems, close, close, disableAllInteractions, disableItemDrop, disableItemPlace, disableItemSwap, disableItemTake, disableOtherActions, enableAllInteractions, enableItemDrop, enableItemPlace, enableItemSwap, enableItemTake, enableOtherActions, getFiller, getGuiItem, getGuiItems, getInventory, getRows, getTitle, guiType, isUpdating, removeItem, removeItem, removeItem, removeItem, setCloseGuiAction, setDefaultClickAction, setDefaultTopClickAction, setDragAction, setInventory, setItem, setItem, setItem, setOpenGuiAction, setOutsideClickAction, setPlayerInventoryAction, setUpdating, title, updateItem, updateItem, updateItem, updateItem
-
Constructor Details
-
PaginatedGui
public PaginatedGui(int rows, int pageSize, @NotNull @NotNull String title, @NotNull @NotNull Set<InteractionModifier> interactionModifiers) Main constructor to provide a way to create PaginatedGui- Parameters:
rows- The amount of rows the GUI should havepageSize- The page size.title- The GUI's title usingStringinteractionModifiers- A set containing whatInteractionModifierthis GUI should have- Since:
- 3.0.3
-
PaginatedGui
Deprecated.In favor ofPaginatedGui(int, int, String, Set)Old main constructor of the PaginatedGui- Parameters:
rows- The rows the GUI should havepageSize- The pageSizetitle- The GUI's title
-
PaginatedGui
Deprecated.In favor ofPaginatedGui(int, int, String, Set)Alternative constructor that doesn't require thepageSizeto be defined- Parameters:
rows- The rows the GUI should havetitle- The GUI's title
-
PaginatedGui
Deprecated.In favor ofPaginatedGui(int, int, String, Set)Alternative constructor that only requires title- Parameters:
title- The GUI's title
-
-
Method Details
-
setPageSize
Sets the page size- Parameters:
pageSize- The new page size- Returns:
- The GUI for easier use when declaring, works like a builder
-
addItem
Adds anGuiItemto the next available slot in the page area- Parameters:
item- TheGuiItemto add to the page
-
addItem
OverriddenBaseGui.addItem(GuiItem...)to add the items to the page instead -
update
public void update()OverriddenBaseGui.update()to use the paginated open -
updatePageItem
public void updatePageItem(int slot, @NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) Updates the pageGuiItemon 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 usesGuiIteminstead- Parameters:
slot- The slot of the item to updateitem- The new ItemStack
-
updatePageItem
AlternativeupdatePageItem(int, GuiItem)that uses ROWS and COLUMNS instead- Parameters:
row- The row of the slotcol- The columns of the slotitem- The newGuiItem
-
removePageItem
Removes a givenGuiItemfrom the page.- Parameters:
item- TheGuiItemto 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) OverridesBaseGui.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 GUI UsespopulatePage()- Parameters:
player- TheHumanEntityto open it toopenPage- The specific page to open at
-
updateTitle
OverridesBaseGui.updateTitle(String)to use the paginated populator instead Updates the title of the GUI This method may cause LAG if used on a loop- Overrides:
updateTitlein classBaseGui- Parameters:
title- The title to set- Returns:
- The GUI 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 GUI- 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 GUI has- Returns:
- The pages number
-
clearPageItems
public void clearPageItems(boolean update) Clears all previously added page items -
clearPageItems
public void clearPageItems()
-
PaginatedGui(int, int, String, Set)