Class DefaultPaginationSession<C,T,X extends AbstractPageContext<C,T,?>>
java.lang.Object
studio.mevera.lotus.internal.pagination.DefaultPaginationSession<C,T,X>
- All Implemented Interfaces:
PaginationSession<C,T, X>
public abstract class DefaultPaginationSession<C,T,X extends AbstractPageContext<C,T,?>>
extends Object
implements PaginationSession<C,T,X>
Per-player pagination runtime. Captures a snapshot of source items at construction so the page
count is stable for the session's lifetime, then synthesises a PageMenu per navigation.
Subclass and override buildPageMenu(int) to supply a platform-specific menu
(e.g. PaperPaginationSession in lotus-paper uses Adventure Component titles).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AbstractPagination<C, T, X> protected intprotected intprotected final org.bukkit.entity.Player -
Constructor Summary
ConstructorsConstructorDescriptionDefaultPaginationSession(@NotNull AbstractPagination<C, T, X> definition, @NotNull Lotus<C> lotus, @NotNull org.bukkit.entity.Player viewer) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract @NotNull InteractiveMenu<C> buildPageMenu(int pageIndex) Factory method for constructing the page menu for a given index.voidclose()Closes the session and the viewer's inventory.intReturns the current page index.@NotNull AbstractPagination<C, T, ? super X> Returns the shared pagination definition.voidgoTo(int pageIndex) Opens the given page index.voidnext()Opens the next page when possible.voidprevious()Opens the previous page when possible.protected voidvoidreload()Rebuilds the session snapshot and reopens the current page from scratch.sliceFor(int pageIndex) intReturns the total number of pages.@NotNull org.bukkit.entity.Playerviewer()Returns the player viewing this session.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface studio.mevera.lotus.api.pagination.PaginationSession
isFirst, isLast
-
Field Details
-
lotus
-
definition
-
viewer
protected final org.bukkit.entity.Player viewer -
snapshot
-
totalPages
protected int totalPages -
itemsPerPage
protected int itemsPerPage
-
-
Constructor Details
-
DefaultPaginationSession
-
-
Method Details
-
definition
Description copied from interface:PaginationSessionReturns the shared pagination definition.- Specified by:
definitionin interfacePaginationSession<C,T, X extends AbstractPageContext<C, T, ?>>
-
viewer
@NotNull public @NotNull org.bukkit.entity.Player viewer()Description copied from interface:PaginationSessionReturns the player viewing this session.- Specified by:
viewerin interfacePaginationSession<C,T, X extends AbstractPageContext<C, T, ?>>
-
currentIndex
public int currentIndex()Description copied from interface:PaginationSessionReturns the current page index.- Specified by:
currentIndexin interfacePaginationSession<C,T, X extends AbstractPageContext<C, T, ?>>
-
totalPages
public int totalPages()Description copied from interface:PaginationSessionReturns the total number of pages.- Specified by:
totalPagesin interfacePaginationSession<C,T, X extends AbstractPageContext<C, T, ?>>
-
next
public void next()Description copied from interface:PaginationSessionOpens the next page when possible.- Specified by:
nextin interfacePaginationSession<C,T, X extends AbstractPageContext<C, T, ?>>
-
previous
public void previous()Description copied from interface:PaginationSessionOpens the previous page when possible.- Specified by:
previousin interfacePaginationSession<C,T, X extends AbstractPageContext<C, T, ?>>
-
goTo
public void goTo(int pageIndex) Description copied from interface:PaginationSessionOpens the given page index.- Specified by:
goToin interfacePaginationSession<C,T, X extends AbstractPageContext<C, T, ?>>
-
reload
public void reload()Description copied from interface:PaginationSessionRebuilds the session snapshot and reopens the current page from scratch. This recalculates page count and re-renders title, capacity, and content.- Specified by:
reloadin interfacePaginationSession<C,T, X extends AbstractPageContext<C, T, ?>>
-
close
public void close()Description copied from interface:PaginationSessionCloses the session and the viewer's inventory.- Specified by:
closein interfacePaginationSession<C,T, X extends AbstractPageContext<C, T, ?>>
-
buildPageMenu
Factory method for constructing the page menu for a given index. Override in subclasses to produce platform-specific menus with richer title types. -
sliceFor
-
rebuildState
protected void rebuildState()
-