Class CommandPaging

java.lang.Object
com.kamikazejam.kamicommon.command.util.CommandPaging

public class CommandPaging extends Object
Splits already-rendered lines into pages with a titleized header and clickable page-flip arrows. Call it synchronously from inside a command's perform, because it reads the live CommandContext and throws NullPointerException when none is set. The arrows appear only when the command has a parameter named "page" and every parameter before it has a default value; page height defaults to 9 lines for a player and 50 for console.
See Also:
  • Field Details

  • Constructor Details

    • CommandPaging

      public CommandPaging()
  • Method Details

    • titleizedPageTitle

      @NotNull public static @NotNull VersionedComponent titleizedPageTitle(@NotNull @NotNull KamiCommand command, @NotNull @NotNull String title, int pageNum, int pageCount)
      Creates a full titleized page message for a command.
      Parameters:
      command - The command to which this page belongs, used for generating the page flip commands.
      title - The unformatted title, which will be titleized.
      pageNum - The current page number, 1-based (e.g. 1 for the first page).
      pageCount - The total number of pages.
    • getPage

      @NotNull public static @NotNull List<VersionedComponent> getPage(@NotNull @NotNull KamiCommand command, @NotNull @NotNull List<VersionedComponent> lines, int pageNum, @NotNull @NotNull String title)
      Creates a 'page' (list of message lines) linked to the provided command.
      Uses the command context's sender to determine the page height.
      Parameters:
      command - The command to which this page belongs, used for generating the page flip commands.
      lines - The lines of 'content' to paginate. This should be ALL the lines you want to show, not just the ones for this page.
      pageNum - The page number, 1-based (e.g. 1 for the first page).
      title - The unformatted title, which will be titleized.
      Returns:
      The ordered list of VersionedComponent objects, for sending to any Player or CommandSender.
    • getPage

      @NotNull public static @NotNull List<VersionedComponent> getPage(@NotNull @NotNull KamiCommand command, @NotNull @NotNull List<VersionedComponent> lines, int pageNum, @NotNull @NotNull String title, int pageheight)
      Creates a 'page' (list of message lines) linked to the provided command.
      Parameters:
      command - The command to which this page belongs, used for generating the page flip commands.
      lines - The lines of 'content' to paginate. This should be ALL the lines you want to show, not just the ones for this page.
      pageNum - The page number, 1-based (e.g. 1 for the first page).
      title - The unformatted title, which will be titleized.
      pageheight - The height of an individual page, in lines.
      Returns:
      The ordered list of VersionedComponent objects, for sending to any Player or CommandSender.