Class PagedInventoryImpl
- java.lang.Object
-
- com.mrivanplays.pagedinventory.internal.PagedInventoryImpl
-
- All Implemented Interfaces:
PagedInventory
public class PagedInventoryImpl extends Object implements PagedInventory
-
-
Constructor Summary
Constructors Constructor Description PagedInventoryImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOnClickFunction(@NotNull Consumer<PageClick> onClick)Adds a click listener, when aPagegot clicked.voidaddOnCloseFunction(@NotNull Consumer<PageClose> onClose)Adds a close listener, when aPagegot closed.voidaddPage(@NotNull Page page)Adds aPageto thisPagedInventory@NotNull Map<Integer,NavigationItem>getNavigationItems()Returns a immutable map of theNavigationItemsadded.@NotNull Optional<Page>getPage(int page)Retrieves the page specified.@NotNull Optional<Page>getPage(@NotNull UUID page)Retrieves the page by the specified page uuid@NotNull UUIDgetPagedInventoryUUID()Returns theUniqueIdof thisPagedInventory, in case you want to store it somewhere@NotNull OptionalIntgetPageNumber(@NotNull Page page)Retrieves the page number of the page specified.@NotNull OptionalIntgetPageNumber(@NotNull UUID page)Retrieves the page number of the page uuid specified@NotNull Map<Integer,Page>getPages()Returns a immutable map of thePagesthisPagedInventoryhas@NotNull Optional<Page>getPageViewed(@NotNull org.bukkit.entity.Player viewer)Returns the page, currently viewed by the specifiedPlayerviewer@NotNull Map<UUID,UUID>getViewers()voidopen(@NotNull org.bukkit.entity.Player viewer, int page)Opens the specified page and adds thePlayerto the cache.voidopenNext(@NotNull org.bukkit.entity.Player viewer)Opens the next page of the page viewed by the player if presentvoidopenPrevious(@NotNull org.bukkit.entity.Player viewer)Opens the previous page of the page viewed by the player if presentvoidremoveNavigationItem(int pos)Removes the specifiedNavigationItemon that position.voidremovePage(int page)Removes the specified page from thisPagedInventoryvoidsetNavigationItem(int pos, @NotNull NavigationItem item)Sets the specifiedNavigationItemon the specifiedInventoryposition.voidsetPage(int pageNum, @NotNull Page page)
-
-
-
Method Detail
-
addOnClickFunction
public void addOnClickFunction(@NotNull @NotNull Consumer<PageClick> onClick)Description copied from interface:PagedInventoryAdds a click listener, when aPagegot clicked.- Specified by:
addOnClickFunctionin interfacePagedInventory- Parameters:
onClick- on click function
-
addOnCloseFunction
public void addOnCloseFunction(@NotNull @NotNull Consumer<PageClose> onClose)Description copied from interface:PagedInventoryAdds a close listener, when aPagegot closed.- Specified by:
addOnCloseFunctionin interfacePagedInventory- Parameters:
onClose- on close function
-
getPage
@NotNull public @NotNull Optional<Page> getPage(int page)
Description copied from interface:PagedInventoryRetrieves the page specified.- Specified by:
getPagein interfacePagedInventory- Parameters:
page- the page you want to retrieve- Returns:
- empty optional if page wasn't found, or else optional with value
-
getPage
@NotNull public @NotNull Optional<Page> getPage(@NotNull @NotNull UUID page)
Description copied from interface:PagedInventoryRetrieves the page by the specified page uuid- Specified by:
getPagein interfacePagedInventory- Parameters:
page- page uuid- Returns:
- empty optional if page wasn't found, or else optional with value
-
getPageNumber
@NotNull public @NotNull OptionalInt getPageNumber(@NotNull @NotNull Page page)
Description copied from interface:PagedInventoryRetrieves the page number of the page specified.- Specified by:
getPageNumberin interfacePagedInventory- Parameters:
page- the page object you want to get numbe- Returns:
- number of the page if present
-
getPageNumber
@NotNull public @NotNull OptionalInt getPageNumber(@NotNull @NotNull UUID page)
Description copied from interface:PagedInventoryRetrieves the page number of the page uuid specified- Specified by:
getPageNumberin interfacePagedInventory- Parameters:
page- page uuid- Returns:
- number of the page if present
-
addPage
public void addPage(@NotNull @NotNull Page page)Description copied from interface:PagedInventoryAdds aPageto thisPagedInventory- Specified by:
addPagein interfacePagedInventory- Parameters:
page- the page you want to add
-
setPage
public void setPage(int pageNum, @NotNull @NotNull Page page)Description copied from interface:PagedInventory- Specified by:
setPagein interfacePagedInventory- Parameters:
pageNum- the page number you want to override/setpage- the page you want to set
-
removePage
public void removePage(int page)
Description copied from interface:PagedInventoryRemoves the specified page from thisPagedInventory- Specified by:
removePagein interfacePagedInventory- Parameters:
page- the page you want to remove
-
getPages
@NotNull public @NotNull Map<Integer,Page> getPages()
Description copied from interface:PagedInventoryReturns a immutable map of thePagesthisPagedInventoryhas- Specified by:
getPagesin interfacePagedInventory- Returns:
- pages
-
setNavigationItem
public void setNavigationItem(int pos, @NotNull @NotNull NavigationItem item)Description copied from interface:PagedInventorySets the specifiedNavigationItemon the specifiedInventoryposition.- Specified by:
setNavigationItemin interfacePagedInventory- Parameters:
pos- the inventory position you want the item onitem- the navigation item you want to set
-
removeNavigationItem
public void removeNavigationItem(int pos)
Description copied from interface:PagedInventoryRemoves the specifiedNavigationItemon that position.- Specified by:
removeNavigationItemin interfacePagedInventory- Parameters:
pos- the position of the navigation item you want to remove
-
getNavigationItems
@NotNull public @NotNull Map<Integer,NavigationItem> getNavigationItems()
Description copied from interface:PagedInventoryReturns a immutable map of theNavigationItemsadded.- Specified by:
getNavigationItemsin interfacePagedInventory- Returns:
- navigation items
-
open
public void open(@NotNull @NotNull org.bukkit.entity.Player viewer, int page)Description copied from interface:PagedInventoryOpens the specified page and adds thePlayerto the cache.- Specified by:
openin interfacePagedInventory- Parameters:
viewer- viewerpage- page
-
openPrevious
public void openPrevious(@NotNull @NotNull org.bukkit.entity.Player viewer)Description copied from interface:PagedInventoryOpens the previous page of the page viewed by the player if present- Specified by:
openPreviousin interfacePagedInventory- Parameters:
viewer- player viewer
-
openNext
public void openNext(@NotNull @NotNull org.bukkit.entity.Player viewer)Description copied from interface:PagedInventoryOpens the next page of the page viewed by the player if present- Specified by:
openNextin interfacePagedInventory- Parameters:
viewer- player viewer
-
getPageViewed
@NotNull public @NotNull Optional<Page> getPageViewed(@NotNull @NotNull org.bukkit.entity.Player viewer)
Description copied from interface:PagedInventoryReturns the page, currently viewed by the specifiedPlayerviewer- Specified by:
getPageViewedin interfacePagedInventory- Parameters:
viewer- player viewer- Returns:
- page viewed if present
-
getViewers
@NotNull public @NotNull Map<UUID,UUID> getViewers()
Description copied from interface:PagedInventoryReturns a immutable map of the known viewers and the viewed pages, key being aPlayer'sUUID, and value being aPage'sUUID- Specified by:
getViewersin interfacePagedInventory- Returns:
- viewers
-
getPagedInventoryUUID
@NotNull public @NotNull UUID getPagedInventoryUUID()
Description copied from interface:PagedInventoryReturns theUniqueIdof thisPagedInventory, in case you want to store it somewhere- Specified by:
getPagedInventoryUUIDin interfacePagedInventory- Returns:
- unique id
-
-