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 void
addOnClickFunction(@NotNull Consumer<PageClick> onClick)
Adds a click listener, when aPage
got clicked.void
addOnCloseFunction(@NotNull Consumer<PageClose> onClose)
Adds a close listener, when aPage
got closed.void
addPage(@NotNull Page page)
Adds aPage
to thisPagedInventory
@NotNull Map<Integer,NavigationItem>
getNavigationItems()
Returns a immutable map of theNavigationItems
added.@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 UUID
getPagedInventoryUUID()
Returns theUniqueId
of thisPagedInventory
, in case you want to store it somewhere@NotNull OptionalInt
getPageNumber(@NotNull Page page)
Retrieves the page number of the page specified.@NotNull OptionalInt
getPageNumber(@NotNull UUID page)
Retrieves the page number of the page uuid specified@NotNull Map<Integer,Page>
getPages()
Returns a immutable map of thePages
thisPagedInventory
has@NotNull Optional<Page>
getPageViewed(@NotNull org.bukkit.entity.Player viewer)
Returns the page, currently viewed by the specifiedPlayer
viewer@NotNull Map<UUID,UUID>
getViewers()
void
open(@NotNull org.bukkit.entity.Player viewer, int page)
Opens the specified page and adds thePlayer
to the cache.void
openNext(@NotNull org.bukkit.entity.Player viewer)
Opens the next page of the page viewed by the player if presentvoid
openPrevious(@NotNull org.bukkit.entity.Player viewer)
Opens the previous page of the page viewed by the player if presentvoid
removeNavigationItem(int pos)
Removes the specifiedNavigationItem
on that position.void
removePage(int page)
Removes the specified page from thisPagedInventory
void
setNavigationItem(int pos, @NotNull NavigationItem item)
Sets the specifiedNavigationItem
on the specifiedInventory
position.void
setPage(int pageNum, @NotNull Page page)
-
-
-
Method Detail
-
addOnClickFunction
public void addOnClickFunction(@NotNull @NotNull Consumer<PageClick> onClick)
Description copied from interface:PagedInventory
Adds a click listener, when aPage
got clicked.- Specified by:
addOnClickFunction
in interfacePagedInventory
- Parameters:
onClick
- on click function
-
addOnCloseFunction
public void addOnCloseFunction(@NotNull @NotNull Consumer<PageClose> onClose)
Description copied from interface:PagedInventory
Adds a close listener, when aPage
got closed.- Specified by:
addOnCloseFunction
in interfacePagedInventory
- Parameters:
onClose
- on close function
-
getPage
@NotNull public @NotNull Optional<Page> getPage(int page)
Description copied from interface:PagedInventory
Retrieves the page specified.- Specified by:
getPage
in 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:PagedInventory
Retrieves the page by the specified page uuid- Specified by:
getPage
in 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:PagedInventory
Retrieves the page number of the page specified.- Specified by:
getPageNumber
in 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:PagedInventory
Retrieves the page number of the page uuid specified- Specified by:
getPageNumber
in interfacePagedInventory
- Parameters:
page
- page uuid- Returns:
- number of the page if present
-
addPage
public void addPage(@NotNull @NotNull Page page)
Description copied from interface:PagedInventory
Adds aPage
to thisPagedInventory
- Specified by:
addPage
in 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:
setPage
in 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:PagedInventory
Removes the specified page from thisPagedInventory
- Specified by:
removePage
in interfacePagedInventory
- Parameters:
page
- the page you want to remove
-
getPages
@NotNull public @NotNull Map<Integer,Page> getPages()
Description copied from interface:PagedInventory
Returns a immutable map of thePages
thisPagedInventory
has- Specified by:
getPages
in interfacePagedInventory
- Returns:
- pages
-
setNavigationItem
public void setNavigationItem(int pos, @NotNull @NotNull NavigationItem item)
Description copied from interface:PagedInventory
Sets the specifiedNavigationItem
on the specifiedInventory
position.- Specified by:
setNavigationItem
in 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:PagedInventory
Removes the specifiedNavigationItem
on that position.- Specified by:
removeNavigationItem
in 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:PagedInventory
Returns a immutable map of theNavigationItems
added.- Specified by:
getNavigationItems
in interfacePagedInventory
- Returns:
- navigation items
-
open
public void open(@NotNull @NotNull org.bukkit.entity.Player viewer, int page)
Description copied from interface:PagedInventory
Opens the specified page and adds thePlayer
to the cache.- Specified by:
open
in interfacePagedInventory
- Parameters:
viewer
- viewerpage
- page
-
openPrevious
public void openPrevious(@NotNull @NotNull org.bukkit.entity.Player viewer)
Description copied from interface:PagedInventory
Opens the previous page of the page viewed by the player if present- Specified by:
openPrevious
in interfacePagedInventory
- Parameters:
viewer
- player viewer
-
openNext
public void openNext(@NotNull @NotNull org.bukkit.entity.Player viewer)
Description copied from interface:PagedInventory
Opens the next page of the page viewed by the player if present- Specified by:
openNext
in interfacePagedInventory
- Parameters:
viewer
- player viewer
-
getPageViewed
@NotNull public @NotNull Optional<Page> getPageViewed(@NotNull @NotNull org.bukkit.entity.Player viewer)
Description copied from interface:PagedInventory
Returns the page, currently viewed by the specifiedPlayer
viewer- Specified by:
getPageViewed
in interfacePagedInventory
- Parameters:
viewer
- player viewer- Returns:
- page viewed if present
-
getViewers
@NotNull public @NotNull Map<UUID,UUID> getViewers()
Description copied from interface:PagedInventory
Returns a immutable map of the known viewers and the viewed pages, key being aPlayer
'sUUID
, and value being aPage
'sUUID
- Specified by:
getViewers
in interfacePagedInventory
- Returns:
- viewers
-
getPagedInventoryUUID
@NotNull public @NotNull UUID getPagedInventoryUUID()
Description copied from interface:PagedInventory
Returns theUniqueId
of thisPagedInventory
, in case you want to store it somewhere- Specified by:
getPagedInventoryUUID
in interfacePagedInventory
- Returns:
- unique id
-
-