Interface PagedInventory
-
- All Known Implementing Classes:
PagedInventoryImpl
public interface PagedInventory
Represents a paged inventory
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract 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
static PagedInventoryBuilder
builder(@NotNull org.bukkit.plugin.Plugin plugin)
Creates a new builder for a paged inventory.@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
-
builder
static PagedInventoryBuilder builder(@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
Creates a new builder for a paged inventory.
This is just a shortcut toPagedInventoryBuilder.createBuilder(Plugin)
- Parameters:
plugin
- plugin owning- Returns:
- builder
-
addOnClickFunction
void addOnClickFunction(@NotNull @NotNull Consumer<PageClick> onClick)
Adds a click listener, when aPage
got clicked.- Parameters:
onClick
- on click function
-
addOnCloseFunction
void addOnCloseFunction(@NotNull @NotNull Consumer<PageClose> onClose)
Adds a close listener, when aPage
got closed.- Parameters:
onClose
- on close function
-
getPage
@NotNull @NotNull Optional<Page> getPage(int page)
Retrieves the page specified.- Parameters:
page
- the page you want to retrieve- Returns:
- empty optional if page wasn't found, or else optional with value
-
getPage
@NotNull @NotNull Optional<Page> getPage(@NotNull @NotNull UUID page)
Retrieves the page by the specified page uuid- Parameters:
page
- page uuid- Returns:
- empty optional if page wasn't found, or else optional with value
-
getPageNumber
@NotNull @NotNull OptionalInt getPageNumber(@NotNull @NotNull Page page)
Retrieves the page number of the page specified.- Parameters:
page
- the page object you want to get numbe- Returns:
- number of the page if present
-
getPageNumber
@NotNull @NotNull OptionalInt getPageNumber(@NotNull @NotNull UUID page)
Retrieves the page number of the page uuid specified- Parameters:
page
- page uuid- Returns:
- number of the page if present
-
addPage
void addPage(@NotNull @NotNull Page page)
Adds aPage
to thisPagedInventory
- Parameters:
page
- the page you want to add
-
setPage
void setPage(int pageNum, @NotNull @NotNull Page page)
- Parameters:
pageNum
- the page number you want to override/setpage
- the page you want to set
-
removePage
void removePage(int page)
Removes the specified page from thisPagedInventory
- Parameters:
page
- the page you want to remove
-
getPages
@NotNull @NotNull Map<Integer,Page> getPages()
Returns a immutable map of thePages
thisPagedInventory
has- Returns:
- pages
-
setNavigationItem
void setNavigationItem(int pos, @NotNull @NotNull NavigationItem item)
Sets the specifiedNavigationItem
on the specifiedInventory
position.- Parameters:
pos
- the inventory position you want the item onitem
- the navigation item you want to set
-
removeNavigationItem
void removeNavigationItem(int pos)
Removes the specifiedNavigationItem
on that position.- Parameters:
pos
- the position of the navigation item you want to remove
-
getNavigationItems
@NotNull @NotNull Map<Integer,NavigationItem> getNavigationItems()
Returns a immutable map of theNavigationItems
added.- Returns:
- navigation items
-
open
void open(@NotNull @NotNull org.bukkit.entity.Player viewer, int page)
Opens the specified page and adds thePlayer
to the cache.- Parameters:
viewer
- viewerpage
- page
-
openPrevious
void openPrevious(@NotNull @NotNull org.bukkit.entity.Player viewer)
Opens the previous page of the page viewed by the player if present- Parameters:
viewer
- player viewer
-
openNext
void openNext(@NotNull @NotNull org.bukkit.entity.Player viewer)
Opens the next page of the page viewed by the player if present- Parameters:
viewer
- player viewer
-
getPageViewed
@NotNull @NotNull Optional<Page> getPageViewed(@NotNull @NotNull org.bukkit.entity.Player viewer)
Returns the page, currently viewed by the specifiedPlayer
viewer- Parameters:
viewer
- player viewer- Returns:
- page viewed if present
-
getViewers
@NotNull @NotNull Map<UUID,UUID> getViewers()
Returns a immutable map of the known viewers and the viewed pages, key being aPlayer
'sUUID
, and value being aPage
'sUUID
- Returns:
- viewers
-
getPagedInventoryUUID
@NotNull @NotNull UUID getPagedInventoryUUID()
Returns theUniqueId
of thisPagedInventory
, in case you want to store it somewhere- Returns:
- unique id
-
-