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
public class PaginatedGui extends BaseGui
GUI that allows you to have multiple pages
-
Constructor Summary
Constructors Constructor Description PaginatedGui(int rows, int pageSize, @NotNull java.lang.String title)
Deprecated.In favor ofPaginatedGui(int, int, Component)
PaginatedGui(int rows, int pageSize, @NotNull net.kyori.adventure.text.Component title)
Alternative constructor of the PaginatedGui, usesComponent
and provides a way to create PaginatedGui that don't use anyInteractionModifier
PaginatedGui(int rows, int pageSize, @NotNull net.kyori.adventure.text.Component title, @NotNull java.util.Set<InteractionModifier> interactionModifiers)
Main constructor to provide a way to create PaginatedGui, usesComponent
PaginatedGui(int rows, @NotNull java.lang.String title)
Deprecated.In favor ofPaginatedGui(int, Component)
PaginatedGui(int rows, @NotNull net.kyori.adventure.text.Component title)
Alternative constructor for thePaginatedGui
without page sizePaginatedGui(@NotNull java.lang.String title)
Deprecated.In favor ofPaginatedGui(Component)
PaginatedGui(@NotNull net.kyori.adventure.text.Component title)
Alternative constructor that only requires title -
Method Summary
Modifier and Type Method Description void
addItem(@NotNull GuiItem item)
Adds anGuiItem
to the next available slot in the page areavoid
addItem(@NotNull GuiItem... items)
OverriddenBaseGui.addItem(GuiItem...)
to add the items to the page insteadjava.util.Map<java.lang.Integer,GuiItem>
getCurrentPageItems()
Gets an immutableMap
with all the current pages itemsint
getCurrentPageNum()
Gets the current page numberint
getNextPageNum()
Gets the next page numberjava.util.List<GuiItem>
getPageItems()
Gets an immutableList
with all the page items added to the GUIint
getPagesNum()
Gets the number of pages the GUI hasint
getPrevPageNum()
Gets the previous page numberboolean
next()
Goes to the next pageboolean
nextPage()
Deprecated.Usenext()
insteadvoid
open(@NotNull org.bukkit.entity.HumanEntity player)
OverridesBaseGui.open(HumanEntity)
to use the paginated populator insteadvoid
open(@NotNull org.bukkit.entity.HumanEntity player, int openPage)
Specific open method for the Paginated GUI UsespopulatePage()
boolean
previous()
Goes to the previous page if possibleboolean
prevPage()
Deprecated.Useprevious()
insteadBaseGui
setPageSize(int pageSize)
Sets the page sizevoid
update()
OverriddenBaseGui.update()
to use the paginated openvoid
updatePageItem(int row, int col, @NotNull GuiItem item)
AlternativeupdatePageItem(int, GuiItem)
that uses ROWS and COLUMNS insteadvoid
updatePageItem(int row, int col, @NotNull org.bukkit.inventory.ItemStack itemStack)
AlternativeupdatePageItem(int, ItemStack)
that uses ROWS and COLUMNS insteadvoid
updatePageItem(int slot, @NotNull GuiItem item)
AlternativeupdatePageItem(int, ItemStack)
that usesGuiItem
insteadvoid
updatePageItem(int slot, @NotNull org.bukkit.inventory.ItemStack itemStack)
Updates the pageGuiItem
on the slot in the page Can get the slot fromInventoryClickEvent.getSlot()
BaseGui
updateTitle(@NotNull java.lang.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 loopBaseGui
updateTitle(@NotNull net.kyori.adventure.text.Component title)
Updates the title of the GUI.Methods inherited from class dev.triumphteam.gui.guis.BaseGui
addSlotAction, addSlotAction, canPlaceItems, canSwapItems, canTakeItems, close, close, disableAllInteractions, disableItemPlace, disableItemSwap, disableItemTake, enableAllInteractions, enableItemPlace, enableItemSwap, enableItemTake, getFiller, getGuiItem, getGuiItems, getInventory, getRows, guiType, isUpdating, removeItem, removeItem, setCloseGuiAction, setDefaultClickAction, setDefaultTopClickAction, setDragAction, setInventory, setItem, setItem, setItem, setOpenGuiAction, setOutsideClickAction, setPlayerInventoryAction, setUpdating, updateItem, updateItem, updateItem, updateItem
-
Constructor Details
-
PaginatedGui
public PaginatedGui(int rows, int pageSize, @NotNull @NotNull net.kyori.adventure.text.Component title, @NotNull @NotNull java.util.Set<InteractionModifier> interactionModifiers)Main constructor to provide a way to create PaginatedGui, usesComponent
- Parameters:
rows
- The amount of rows the GUI should havetitle
- The GUI's title usingComponent
interactionModifiers
- A set containing whatInteractionModifier
this GUI should have- Since:
- 3.0.0
-
PaginatedGui
public PaginatedGui(int rows, int pageSize, @NotNull @NotNull net.kyori.adventure.text.Component title)Alternative constructor of the PaginatedGui, usesComponent
and provides a way to create PaginatedGui that don't use anyInteractionModifier
- Parameters:
rows
- The rows the GUI should havepageSize
- The pageSizetitle
- The title usingComponent
- Since:
- 3.0.0
-
PaginatedGui
public PaginatedGui(int rows, @NotNull @NotNull net.kyori.adventure.text.Component title)Alternative constructor for thePaginatedGui
without page size- Parameters:
title
- The title usingComponent
- Since:
- 3.0.0
-
PaginatedGui
public PaginatedGui(@NotNull @NotNull net.kyori.adventure.text.Component title)Alternative constructor that only requires title- Parameters:
title
- The title usingComponent
- Since:
- 3.0.0
-
PaginatedGui
@Deprecated public PaginatedGui(int rows, int pageSize, @NotNull @NotNull java.lang.String title)Deprecated.In favor ofPaginatedGui(int, int, Component)
Old main constructor of the PaginatedGui- Parameters:
rows
- The rows the GUI should havepageSize
- The pageSizetitle
- The GUI's title
-
PaginatedGui
@Deprecated public PaginatedGui(int rows, @NotNull @NotNull java.lang.String title)Deprecated.In favor ofPaginatedGui(int, Component)
Alternative constructor that doesn't require thepageSize
to be defined- Parameters:
rows
- The rows the GUI should havetitle
- The GUI's title
-
PaginatedGui
@Deprecated public PaginatedGui(@NotNull @NotNull java.lang.String title)Deprecated.In favor ofPaginatedGui(Component)
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 anGuiItem
to the next available slot in the page area- Parameters:
item
- TheGuiItem
to 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 pageGuiItem
on 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 usesGuiItem
instead- 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
-
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
- TheHumanEntity
to 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:
updateTitle
in classBaseGui
- Parameters:
title
- The title to set- Returns:
- The GUI for easier use when declaring, works like a builder
-
updateTitle
Description copied from class:BaseGui
Updates the title of the GUI. I do not recommend using this too often.- Overrides:
updateTitle
in classBaseGui
- Parameters:
title
- The title to set.- Returns:
- The GUI for easier use when declaring, works like a builder.
-
getCurrentPageItems
Gets an immutableMap
with all the current pages items- Returns:
- The
Map
with all thecurrentPage
-
getPageItems
Gets an immutableList
with all the page items added to the GUI- Returns:
- The
List
with 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
pageNum
if no next is present
-
getPrevPageNum
public int getPrevPageNum()Gets the previous page number- Returns:
- The previous page number or
pageNum
if no previous is present
-
next
public boolean next()Goes to the next page -
nextPage
@Deprecated public boolean nextPage()Deprecated.Usenext()
insteadGoes to the next page -
previous
public boolean previous()Goes to the previous page if possible -
prevPage
@Deprecated public boolean prevPage()Deprecated.Useprevious()
insteadGoes to the previous page if possible -
getPagesNum
public int getPagesNum()Gets the number of pages the GUI has- Returns:
- The pages number
-