Class Pager<PagedElement>
java.lang.Object
com.datdeveloper.datmoddingapi.command.util.Pager<PagedElement>
- Type Parameters:
PagedElement
- The type of the item being paged
A class to split the results of a command into pages
Commands that implement this should take an integer as the last argument that is passed to the
sendPage(int, CommandSource)
method-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A Functional interface to transform the given PagedElement into a Chat Component -
Constructor Summary
ConstructorDescriptionPager
(@NotNull String command, @Nullable String headerText, int elementsPerPage, @NotNull Collection<? extends PagedElement> elements, @NotNull Pager.ElementTransformer<PagedElement> transformer) Construct a pagerPager
(String command, @Nullable String headerText, Collection<? extends PagedElement> elements, Pager.ElementTransformer<PagedElement> transformer) Construct a pager with the default amount of items per page (10) -
Method Summary
Modifier and TypeMethodDescriptionprotected net.minecraft.network.chat.Component
getFooter
(int page) protected net.minecraft.network.chat.Component
Get the header for the pagerprotected net.minecraft.network.chat.Component
getPage
(int page) void
sendPage
(int page, net.minecraft.commands.CommandSource source) Send the given page to the givenCommandSource
-
Constructor Details
-
Pager
public Pager(String command, @Nullable @Nullable String headerText, Collection<? extends PagedElement> elements, Pager.ElementTransformer<PagedElement> transformer) Construct a pager with the default amount of items per page (10)- Parameters:
command
- The command usedheaderText
- The heading of the pagerelements
- A list of the elements being pagedtransformer
- The function that converts the elements into a chat component
-
Pager
public Pager(@NotNull @NotNull String command, @Nullable @Nullable String headerText, int elementsPerPage, @NotNull @NotNull Collection<? extends PagedElement> elements, @NotNull @NotNull Pager.ElementTransformer<PagedElement> transformer) Construct a pager- Parameters:
command
- The command usedheaderText
- The heading of the pagerelementsPerPage
- The amount of elements per pageelements
- A list of the elements being pagedtransformer
- The function that converts the elements into a chat component
-
-
Method Details
-
getHeader
protected net.minecraft.network.chat.Component getHeader()Get the header for the pager- Returns:
- The header for the pager
-
getPage
protected net.minecraft.network.chat.Component getPage(int page) -
sendPage
public void sendPage(int page, net.minecraft.commands.CommandSource source) Send the given page to the givenCommandSource
- Parameters:
page
- The page to show to the CommandSourcesource
- The command source to send the page to
-