Class Paginator.Builder

Enclosing class:
Paginator

public static class Paginator.Builder extends Menu.Builder<Paginator.Builder,Paginator>
Author:
John Grosh
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • build

      public Paginator build()
      Builds the Paginator with this Builder.
      Specified by:
      build in class Menu.Builder<Paginator.Builder,Paginator>
      Returns:
      The Paginator built from this Builder.
      Throws:
      IllegalArgumentException - If one of the following is violated:
      • No EventWaiter was set.
      • No items were set to paginate.
    • setColor

      public Paginator.Builder setColor(Color color)
      Sets the Color of the MessageEmbed.
      Parameters:
      color - The Color of the MessageEmbed
      Returns:
      This builder
    • setColor

      public Paginator.Builder setColor(BiFunction<Integer,Integer,Color> colorBiFunction)
      Sets the Color of the MessageEmbed, relative to the total page number and the current page as determined by the provided BiFunction.
      As the page changes, the BiFunction will re-process the current page number and the total page number, allowing for the color of the embed to change depending on the page number.
      Parameters:
      colorBiFunction - A BiFunction that uses both current and total page numbers to get a Color for the MessageEmbed
      Returns:
      This builder
    • setText

      public Paginator.Builder setText(String text)
      Sets the text of the Message to be displayed when the Paginator is built.

      This is displayed directly above the embed.

      Parameters:
      text - The Message content to be displayed above the embed when the Paginator is built
      Returns:
      This builder
    • setText

      public Paginator.Builder setText(BiFunction<Integer,Integer,String> textBiFunction)
      Sets the text of the Message to be displayed relative to the total page number and the current page as determined by the provided BiFunction.
      As the page changes, the BiFunction will re-process the current page number and the total page number, allowing for the displayed text of the Message to change depending on the page number.
      Parameters:
      textBiFunction - The BiFunction that uses both current and total page numbers to get text for the Message
      Returns:
      This builder
    • setFinalAction

      public Paginator.Builder setFinalAction(Consumer<net.dv8tion.jda.api.entities.Message> finalAction)
      Sets the Consumer to perform if the Paginator times out.
      Parameters:
      finalAction - The Consumer action to perform if the Paginator times out
      Returns:
      This builder
    • setColumns

      public Paginator.Builder setColumns(int columns)
      Sets the number of columns each page will have.
      By default this is 1.
      Parameters:
      columns - The number of columns
      Returns:
      This builder
    • setItemsPerPage

      public Paginator.Builder setItemsPerPage(int num)
      Sets the number of items that will appear on each page.
      Parameters:
      num - Always positive, never-zero number of items per page
      Returns:
      This builder
      Throws:
      IllegalArgumentException - If the provided number is less than 1
    • showPageNumbers

      public Paginator.Builder showPageNumbers(boolean show)
      Sets whether or not the page number will be shown.
      Parameters:
      show - true if the page number should be shown, false if it should not
      Returns:
      This builder
    • useNumberedItems

      public Paginator.Builder useNumberedItems(boolean number)
      Sets whether or not the items will be automatically numbered.
      Parameters:
      number - true if the items should be numbered, false if it should not
      Returns:
      This builder
    • waitOnSinglePage

      public Paginator.Builder waitOnSinglePage(boolean wait)
      Sets whether the Paginator will instantly timeout, and possibly run a provided Runnable, if only a single slide is available to display.
      Parameters:
      wait - true if the Paginator will still generate
      Returns:
      This builder
    • clearItems

      public Paginator.Builder clearItems()
      Clears the list of String items to paginate.
      Returns:
      This builder
    • addItems

      public Paginator.Builder addItems(String... items)
      Adds String items to the list of items to paginate.
      Parameters:
      items - The String list of items to add
      Returns:
      This builder
    • setItems

      public Paginator.Builder setItems(String... items)
      Sets the String list of items to paginate.
      This method clears all previously set items before setting.
      Parameters:
      items - The String list of items to paginate
      Returns:
      This builder
    • getItems

      public List<String> getItems()
      Gets the String list of items to paginate.
      Useful when determining amount of items are being paginated.
      Returns:
      the String list
    • setBulkSkipNumber

      public Paginator.Builder setBulkSkipNumber(int bulkSkipNumber)
      Sets the Paginator's bulk-skip function to skip multiple pages using alternate forward and backwards
      Parameters:
      bulkSkipNumber - The number of pages to skip when the bulk-skip reactions are used.
      Returns:
      This builder
    • wrapPageEnds

      public Paginator.Builder wrapPageEnds(boolean wrapPageEnds)
      Sets the Paginator to wrap from the last page to the first when traversing right and visa versa from the left.
      Parameters:
      wrapPageEnds - true to enable wrapping.
      Returns:
      This builder
    • allowTextInput

      public Paginator.Builder allowTextInput(boolean allowTextInput)
      Sets the Paginator to allow a page number to be specified by a user via text.

      Note that setting this doesn't mean that left and right text inputs provided via setLeftRightText(String, String) will be invalidated if they were set previously! To invalidate those, provide null for one or both of the parameters of that method.

      Parameters:
      allowTextInput - true if the Paginator will allow page-number text input
      Returns:
      This builder
    • setLeftRightText

      public Paginator.Builder setLeftRightText(String left, String right)
      Sets the Paginator to traverse left or right when a provided text input is sent in the form of a Message to the GuildChannel the menu is displayed in.

      If one or both these parameters are provided null this resets both of them and they will no longer be available when the Paginator is built.

      Parameters:
      left - The left text input, causes the Paginator to traverse one page left
      right - The right text input, causes the Paginator to traverse one page right
      Returns:
      This builder