Class PaginatedPane
java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
com.github.stefvanschie.inventoryframework.pane.PaginatedPane
A pane for panes that should be spread out over multiple pages
-
Nested Class Summary
Nested classes/interfaces inherited from class com.github.stefvanschie.inventoryframework.pane.Pane
Pane.Priority
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPaginatedPane
(int length, int height) PaginatedPane
(int x, int y, int length, int height) PaginatedPane
(int x, int y, int length, int height, @NotNull Pane.Priority priority) PaginatedPane
(@NotNull Slot slot, int length, int height) Creates a new paginated panePaginatedPane
(@NotNull Slot slot, int length, int height, @NotNull Pane.Priority priority) Creates a new paginated pane -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the specified pane to a new page.void
Assigns a pane to a selected pagevoid
clear()
Clears the entire pane of any items/panes.boolean
click
(@NotNull Gui gui, @NotNull InventoryComponent inventoryComponent, @NotNull InventoryClickEvent event, int slot, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Called whenever there is being clicked on this pane@NotNull PaginatedPane
copy()
Makes a copy of this pane and returns it.void
deletePage
(int page) Deletes a page and all its associated panes from this paginated pane.void
display
(@NotNull InventoryComponent inventoryComponent, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Has to set all the items in the right spot inside the inventory@NotNull Collection
<GuiItem> getItems()
Gets all the items in this pane and all underlying panes.int
getPage()
Returns the current pageint
getPages()
Returns the amount of pages@NotNull Collection
<Pane> getPanes()
Gets all the panes in this panes, including any child panes from other panes.@NotNull Collection
<Pane> getPanes
(int page) Gets all the panes from inside the specified page of this pane.static @NotNull PaginatedPane
Deprecated.static @NotNull PaginatedPane
Loads a paginated pane from a given elementvoid
populateWithGuiItems
(@NotNull List<GuiItem> items) Populates the PaginatedPane based on the provided list by adding new pages until all items can fit.void
populateWithItemStacks
(@NotNull List<@NotNull ItemStack> items, @NotNull Plugin plugin) Populates the PaginatedPane based on the provided list by adding new pages until all items can fit.void
populateWithItemStacks
(@NotNull List<ItemStack> items) Populates the PaginatedPane based on the provided list by adding new pages until all items can fit.void
populateWithNames
(@NotNull List<String> displayNames, @Nullable Material material) This method creates a list of ItemStacks all with the givenmaterial
and the display names.void
populateWithNames
(@NotNull List<String> displayNames, @Nullable Material material, @NotNull Plugin plugin) This method creates a list of ItemStacks all with the givenmaterial
and the display names.void
setPage
(int page) Sets the current displayed pageMethods inherited from class com.github.stefvanschie.inventoryframework.pane.Pane
callOnClick, createBorder, createBorder, findMatchingItem, getHeight, getLength, getPriority, getSlot, getUUID, getX, getY, isVisible, load, loadItem, loadItem, matchesItem, registerProperty, setHeight, setLength, setOnClick, setPriority, setSlot, setVisible, setX, setY
-
Constructor Details
-
PaginatedPane
public PaginatedPane(@NotNull @NotNull Slot slot, int length, int height, @NotNull @NotNull Pane.Priority priority) Creates a new paginated pane- Parameters:
slot
- the slot of the panelength
- the length of the paneheight
- the height of the panepriority
- the priority of the pane- Since:
- 0.10.8
-
PaginatedPane
public PaginatedPane(int x, int y, int length, int height, @NotNull @NotNull Pane.Priority priority) -
PaginatedPane
Creates a new paginated pane- Parameters:
slot
- the slot of the panelength
- the length of the paneheight
- the height of the pane- Since:
- 0.10.8
-
PaginatedPane
public PaginatedPane(int x, int y, int length, int height) -
PaginatedPane
public PaginatedPane(int length, int height)
-
-
Method Details
-
getPage
public int getPage()Returns the current page- Returns:
- the current page
-
getPages
public int getPages()Returns the amount of pages- Returns:
- the amount of pages
-
addPage
Adds the specified pane to a new page. The new page will be at the index one after the highest indexed page currently in this paginated pane. If the highest index pane isInteger.MAX_VALUE
, this method will throw anArithmeticException
. If this paginated pane has no pages, the index of the newly created page will be zero.- Parameters:
pane
- the pane to add to a new page- Throws:
ArithmeticException
- if the highest indexed page is the maximum value- Since:
- 0.10.8
-
addPane
Assigns a pane to a selected page- Parameters:
page
- the page to assign the pane topane
- the new pane
-
setPage
public void setPage(int page) Sets the current displayed page- Parameters:
page
- the page
-
populateWithItemStacks
public void populateWithItemStacks(@NotNull @NotNull List<@NotNull ItemStack> items, @NotNull @NotNull Plugin plugin) Populates the PaginatedPane based on the provided list by adding new pages until all items can fit. This can be helpful when dealing with lists of unknown size.- Parameters:
items
- The list to populate the pane withplugin
- the plugin that will be the owner of the items created- Since:
- 0.10.8
- See Also:
-
populateWithItemStacks
Populates the PaginatedPane based on the provided list by adding new pages until all items can fit. This can be helpful when dealing with lists of unknown size.- Parameters:
items
- The list to populate the pane with
-
populateWithGuiItems
Populates the PaginatedPane based on the provided list by adding new pages until all items can fit. This can be helpful when dealing with lists of unknown size.- Parameters:
items
- The list to populate the pane with
-
populateWithNames
public void populateWithNames(@NotNull @NotNull List<String> displayNames, @Nullable @Nullable Material material, @NotNull @NotNull Plugin plugin) This method creates a list of ItemStacks all with the givenmaterial
and the display names. After that it callspopulateWithItemStacks(List)
This method also translates the color char&
for all names.- Parameters:
displayNames
- The display names for all the itemsmaterial
- The material to use for theItemStack
splugin
- the plugin that will be the owner of the created items- Since:
- 0.10.8
- See Also:
-
populateWithNames
public void populateWithNames(@NotNull @NotNull List<String> displayNames, @Nullable @Nullable Material material) This method creates a list of ItemStacks all with the givenmaterial
and the display names. After that it callspopulateWithItemStacks(List)
This method also translates the color char&
for all names.- Parameters:
displayNames
- The display names for all the itemsmaterial
- The material to use for theItemStack
s
-
display
public void display(@NotNull @NotNull InventoryComponent inventoryComponent, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Description copied from class:Pane
Has to set all the items in the right spot inside the inventory- Specified by:
display
in classPane
- Parameters:
inventoryComponent
- the inventory component in which the items should be displayedpaneOffsetX
- the pane's offset on the x axispaneOffsetY
- the pane's offset on the y axismaxLength
- the maximum length of the panemaxHeight
- the maximum height of the pane
-
click
public boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull InventoryComponent inventoryComponent, @NotNull @NotNull InventoryClickEvent event, int slot, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Description copied from class:Pane
Called whenever there is being clicked on this pane- Specified by:
click
in classPane
- Parameters:
gui
- the gui in which was clickedinventoryComponent
- the inventory component in which this pane residesevent
- the event that occurred while clicking on this itemslot
- the slot that was clicked inpaneOffsetX
- the pane's offset on the x axispaneOffsetY
- the pane's offset on the y axismaxLength
- the maximum length of the panemaxHeight
- the maximum height of the pane- Returns:
- whether the item was found or not
-
copy
Description copied from class:Pane
Makes a copy of this pane and returns it. This makes a deep copy of the pane. This entails that the underlying panes and/or items will be copied as well. The returned pane will never be reference equal to the current pane. -
deletePage
public void deletePage(int page) Deletes a page and all its associated panes from this paginated pane. It also decrements the indexes of all pages beyond the specified page by one. For example, given a sequence of pages 0, 1, 2, 3, 4, upon removing page 2, the new sequence of pages will be 0, 1, 2, 3. If the specified page does not exist, then this method will silently do nothing.- Parameters:
page
- the page to delete- Since:
- 0.10.5
-
getPanes
Description copied from class:Pane
Gets all the panes in this panes, including any child panes from other panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.) -
getPanes
Gets all the panes from inside the specified page of this pane. If the specified page is not existent, this method will throw anIllegalArgumentException
. If the specified page is existent, but doesn't have any panes, the returned collection will be empty. The returned collection is unmodifiable. The returned collection is not synchronized and no guarantees should be made as to the safety of concurrently accessing the returned collection. If synchronized behaviour should be allowed, the returned collection must be synchronized externally.- Parameters:
page
- the panes of this page will be returned- Returns:
- a collection of panes belonging to the specified page
- Throws:
IllegalArgumentException
- if the page does not exist- Since:
- 0.5.13
-
getItems
Description copied from class:Pane
Gets all the items in this pane and all underlying panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.) -
clear
public void clear()Description copied from class:Pane
Clears the entire pane of any items/panes. Underlying panes will not be cleared. -
load
@NotNull public static @NotNull PaginatedPane load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element, @NotNull @NotNull Plugin plugin) Loads a paginated pane from a given element- Parameters:
instance
- the instance classelement
- the elementplugin
- the plugin that will be used to create the items- Returns:
- the paginated pane
- Since:
- 0.10.8
-
load
@NotNull @Deprecated public static @NotNull PaginatedPane load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element) Deprecated.this method is no longer used internally and has been superseded byload(Object, Element, Plugin)
Loads a paginated pane from a given element- Parameters:
instance
- the instance classelement
- the element- Returns:
- the paginated pane
-
load(Object, Element, Plugin)