Class Pager<PagedElement>

java.lang.Object
com.datdeveloper.datmoddingapi.command.util.Pager<PagedElement>
Type Parameters:
PagedElement - The type of the item being paged

public class Pager<PagedElement> extends Object
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
  • 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 used
      headerText - The heading of the pager
      elements - A list of the elements being paged
      transformer - 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 used
      headerText - The heading of the pager
      elementsPerPage - The amount of elements per page
      elements - A list of the elements being paged
      transformer - 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)
    • getFooter

      protected net.minecraft.network.chat.Component getFooter(int page)
    • sendPage

      public void sendPage(int page, net.minecraft.commands.CommandSource source)
      Send the given page to the given CommandSource
      Parameters:
      page - The page to show to the CommandSource
      source - The command source to send the page to