Package redempt.redlib.inventorygui
Class PaginationPanel
java.lang.Object
redempt.redlib.inventorygui.PaginationPanel
A panel in an InventoryGUI which can be used to paginate items and buttons
-
Constructor Summary
ConstructorDescriptionConstructs a PaginationPanel to work on a given InventoryGUIPaginationPanel
(InventoryGUI gui, org.bukkit.inventory.ItemStack fillerItem) Constructs a PaginationPanel to work on a given InventoryGUI -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPagedButton
(ItemButton button) Adds a paged button to the panelvoid
addPagedButtons
(Iterable<ItemButton> buttons) Adds multiple buttons to the paged panelvoid
addPagedItem
(org.bukkit.inventory.ItemStack item) Adds a paged item to the panelvoid
addPagedItems
(Iterable<org.bukkit.inventory.ItemStack> items) Adds multiple items to the paged panelvoid
addSlot
(int slot) Adds a slot which will be used to display elementsvoid
addSlots
(int start, int end) Adds a range of slots which will be used to display elementsvoid
addSlots
(int x1, int y1, int x2, int y2) Adds a rectangular area of slots which will be used to display elementsvoid
clear()
Removes all items and buttons from the panelorg.bukkit.inventory.ItemStack
Gets the filler itemList<org.bukkit.inventory.ItemStack>
getItems()
int
int
getPage()
int
void
nextPage()
Navigates to the next page, if there is onevoid
prevPage()
Navigates to the previous page, if there is onevoid
removePagedButton
(ItemButton button) Removes a button from the paged panel.void
removePagedButtons
(Iterable<ItemButton> buttons) Removes multiple buttons from the paged panelvoid
removePagedItem
(org.bukkit.inventory.ItemStack item) Removes an item from the paged panel.void
removePagedItems
(Iterable<org.bukkit.inventory.ItemStack> items) Removes multiple items from the paged panelvoid
removeSlot
(int slot) Removes a slot which will be used to display elementsvoid
removeSlots
(int start, int end) Removes a range of slots which will be used to display elementsvoid
removeSlots
(int x1, int y1, int x2, int y2) Removes a rectangular area of slots which will be used to display elementsvoid
setFillerItem
(org.bukkit.inventory.ItemStack item) Sets the filler itemvoid
setOnUpdate
(Runnable onUpdate) Sets a task to be run whenever the page updates, can be used to update a page indicator or similarvoid
setPage
(int page) Sets the page of this panelvoid
Updates the elements displayed on the current page
-
Constructor Details
-
PaginationPanel
Constructs a PaginationPanel to work on a given InventoryGUI- Parameters:
gui
- The InventoryGUI to paginate
-
PaginationPanel
Constructs a PaginationPanel to work on a given InventoryGUI- Parameters:
gui
- The InventoryGUI to paginatefillerItem
- The item to use for the background
-
-
Method Details
-
setOnUpdate
Sets a task to be run whenever the page updates, can be used to update a page indicator or similar- Parameters:
onUpdate
- The task to be run on update
-
addPagedButton
Adds a paged button to the panel- Parameters:
button
- The button to add
-
addPagedItem
public void addPagedItem(org.bukkit.inventory.ItemStack item) Adds a paged item to the panel- Parameters:
item
- The item to add
-
addPagedButtons
Adds multiple buttons to the paged panel- Parameters:
buttons
- The buttons to add
-
addPagedItems
Adds multiple items to the paged panel- Parameters:
items
- The items to add
-
removePagedItem
public void removePagedItem(org.bukkit.inventory.ItemStack item) Removes an item from the paged panel.- Parameters:
item
- The item to remove
-
removePagedButton
Removes a button from the paged panel.- Parameters:
button
- The button to remove
-
removePagedItems
Removes multiple items from the paged panel- Parameters:
items
- The items to remove
-
removePagedButtons
Removes multiple buttons from the paged panel- Parameters:
buttons
- The buttons to remove
-
getPage
public int getPage()- Returns:
- The page this panel is currently on
-
getPageSize
public int getPageSize()- Returns:
- The max number of elements displayed on each page
-
getMaxPage
public int getMaxPage()- Returns:
- The maximum page number of this panel with the current number of elements
-
addSlot
public void addSlot(int slot) Adds a slot which will be used to display elements- Parameters:
slot
- The slot to add
-
addSlots
public void addSlots(int start, int end) Adds a range of slots which will be used to display elements- Parameters:
start
- The start index of slots to add, inclusiveend
- The end index of slots to add, exclusive
-
addSlots
public void addSlots(int x1, int y1, int x2, int y2) Adds a rectangular area of slots which will be used to display elements- Parameters:
x1
- The starting X of slots to add, inclusivey1
- The starting Y of slots to add, inclusivex2
- The ending X of slots to add, exclusivey2
- The ending Y of slots to add, exclusive
-
removeSlot
public void removeSlot(int slot) Removes a slot which will be used to display elements- Parameters:
slot
- The slot to remove
-
removeSlots
public void removeSlots(int start, int end) Removes a range of slots which will be used to display elements- Parameters:
start
- The start index of slots to remove, inclusiveend
- The end index of slots to remove, exclusive
-
removeSlots
public void removeSlots(int x1, int y1, int x2, int y2) Removes a rectangular area of slots which will be used to display elements- Parameters:
x1
- The starting X of slots to remove, inclusivey1
- The starting Y of slots to remove, inclusivex2
- The ending X of slots to remove, exclusivey2
- The ending Y of slots to remove, exclusive
-
updatePage
public void updatePage()Updates the elements displayed on the current page -
setPage
public void setPage(int page) Sets the page of this panel- Parameters:
page
- The page to set
-
clear
public void clear()Removes all items and buttons from the panel -
getItems
- Returns:
- All ItemStacks added to this panel
-
getButtons
- Returns:
- All ItemButtons added to this panel
-
nextPage
public void nextPage()Navigates to the next page, if there is one -
prevPage
public void prevPage()Navigates to the previous page, if there is one -
setFillerItem
public void setFillerItem(org.bukkit.inventory.ItemStack item) Sets the filler item -
getFillerItem
public org.bukkit.inventory.ItemStack getFillerItem()Gets the filler item
-