Class PaginatedPane
java.lang.Object
me.despical.inventoryframework.pane.Pane
me.despical.inventoryframework.pane.PaginatedPane
A pane for panes that should be spread out over multiple pages
- Since:
- 1.0.1
Created at 04.09.2020
- Author:
- Despical
-
Nested Class Summary
Nested classes/interfaces inherited from class me.despical.inventoryframework.pane.Pane
Pane.Priority -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionPaginatedPane(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) -
Method Summary
Modifier and TypeMethodDescriptionvoidAssigns a pane to a selected pagevoidclear()Clears the entire pane of any items/panes.booleanclick(@NotNull Gui gui, @NotNull org.bukkit.event.inventory.InventoryClickEvent event, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Called whenever there is being clicked on this panevoiddisplay(@NotNull Gui gui, @NotNull org.bukkit.inventory.Inventory inventory, @NotNull org.bukkit.inventory.PlayerInventory playerInventory, 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.intgetPage()Returns the current pageintgetPages()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 PaginatedPaneLoads a paginated pane from a given elementvoidpopulateWithGuiItems(@NotNull List<GuiItem> items) Populates the PaginatedPane based on the provided list by adding new pages until all items can fit.voidpopulateWithItemStacks(@NotNull List<org.bukkit.inventory.ItemStack> items) Populates the PaginatedPane based on the provided list by adding new pages until all items can fit.voidpopulateWithNames(@NotNull List<String> displayNames, @Nullable org.bukkit.Material material) This method creates a list of ItemStacks all with the givenmaterialand the display names.voidsetPage(int page) Sets the current displayed pageMethods inherited from class me.despical.inventoryframework.pane.Pane
findMatchingItem, getHeight, getLength, getPriority, getPropertyMappings, getX, getY, isVisible, load, loadItem, registerProperty, setHeight, setLength, setOnClick, setOnLocalClick, setPriority, setVisible, setX, setY
-
Constructor Details
-
PaginatedPane
public PaginatedPane(int x, int y, int length, int height, @NotNull @NotNull Pane.Priority priority) -
PaginatedPane
public PaginatedPane(int x, int y, int length, int height) -
PaginatedPane
public PaginatedPane(int length, int height)
-
-
Method Details
-
load
@NotNull public static @NotNull PaginatedPane load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element) Loads a paginated pane from a given element- Parameters:
instance- the instance classelement- the element- Returns:
- the paginated pane
-
getPage
public int getPage()Returns the current page- Returns:
- the current page
-
setPage
public void setPage(int page) Sets the current displayed page- Parameters:
page- the page
-
getPages
public int getPages()Returns the amount of pages- Returns:
- the amount of pages
-
addPane
Assigns a pane to a selected page- Parameters:
page- the page to assign the pane topane- the new pane
-
populateWithItemStacks
@Contract("null -> fail") public void populateWithItemStacks(@NotNull @NotNull List<org.bukkit.inventory.ItemStack> items) 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
@Contract("null, _ -> fail") public void populateWithNames(@NotNull @NotNull List<String> displayNames, @Nullable @Nullable org.bukkit.Material material) This method creates a list of ItemStacks all with the givenmaterialand 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 theItemStacks
-
display
public void display(@NotNull @NotNull Gui gui, @NotNull @NotNull org.bukkit.inventory.Inventory inventory, @NotNull @NotNull org.bukkit.inventory.PlayerInventory playerInventory, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Description copied from class:PaneHas to set all the items in the right spot inside the inventory- Specified by:
displayin classPane- Parameters:
gui- the gui for which we're renderinginventory- the inventory that the items should be displayed inplayerInventory- the player's inventorypaneOffsetX- 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 org.bukkit.event.inventory.InventoryClickEvent event, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Description copied from class:PaneCalled whenever there is being clicked on this pane- Specified by:
clickin classPane- Parameters:
gui- the gui this event stems fromevent- the event that occurred while clicking on this itempaneOffsetX- 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
-
getPanes
Description copied from class:PaneGets 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:
- 1.0.1
-
getItems
Description copied from class:PaneGets 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:PaneClears the entire pane of any items/panes. Underlying panes will not be cleared.
-