Class PaginatedList


  • public class PaginatedList
    extends java.lang.Object
    A class used to generate MineDown formatted chat menus of paginated list items.

    A paginated list contains the following elements:

    • A header, by default identifying the items listed on the current page
    • The items, separated by new lines by default
    • A footer, by default containing page navigation buttons and quick-jump page numbers
    You can supply ListOptions to modify the format of each element, including shortcuts for modifying a theme color. Once you have created a PaginatedList object using the static get(items, options), you can easily generate a MineDown formatted chat menu for a given page using the getPage() methods.
    See Also:
    ListOptions
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @NotNull de.themoep.minedown.adventure.MineDown getNearestValidPage​(int page)
      Returns a MineDown formatted message to be sent to a player of the paginated list for the nearest specified page that exists
      de.themoep.minedown.adventure.MineDown getPage​(int page)
      Returns a MineDown formatted message to be sent to a player of the paginated list for the specified page
      protected @NotNull java.lang.String getPageJumperButtons​(int page)  
      @NotNull java.lang.String getRawPage​(int page)
      Generates a raw string of pre-MineDown-formatted text that when formatted will create the page menu.
      int getTotalPages()
      Returns the total number of pages
      static @NotNull PaginatedList of​(@NotNull java.util.List<java.lang.String> items)
      Create a new PaginatedList from a List of items
      static @NotNull PaginatedList of​(@NotNull java.util.List<java.lang.String> items, @NotNull ListOptions options)
      Create a new PaginatedList from a List of items
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • of

        @NotNull
        public static @NotNull PaginatedList of​(@NotNull
                                                @NotNull java.util.List<java.lang.String> items)
        Create a new PaginatedList from a List of items
        Parameters:
        items - The List of items to paginate
        Returns:
        A new PaginatedList
      • of

        @NotNull
        public static @NotNull PaginatedList of​(@NotNull
                                                @NotNull java.util.List<java.lang.String> items,
                                                @NotNull
                                                @NotNull ListOptions options)
        Create a new PaginatedList from a List of items
        Parameters:
        items - The List of items to paginate
        options - The ListOptions to use for generating list pages
        Returns:
        A new PaginatedList
      • getNearestValidPage

        @NotNull
        public @NotNull de.themoep.minedown.adventure.MineDown getNearestValidPage​(int page)
        Returns a MineDown formatted message to be sent to a player of the paginated list for the nearest specified page that exists

        List formats and options from the ListOptions are applied to generate list pages.

        #getNearestValidPage() will return the nearest valid page (i.e. values below 0 will be set to 0, values above the maximum page will be set to the maximum page)
        Parameters:
        page - The page number to get
        Returns:
        A MineDown object, for formatting the list
      • getPage

        public de.themoep.minedown.adventure.MineDown getPage​(int page)
                                                       throws PaginationException
        Returns a MineDown formatted message to be sent to a player of the paginated list for the specified page

        List formats and options from the ListOptions are applied to generate the list.

        Parameters:
        page - The page number to get
        Returns:
        A MineDown object, for formatting the list
        Throws:
        PaginationException - If the page number is out of bounds
      • getRawPage

        @NotNull
        public @NotNull java.lang.String getRawPage​(int page)
                                             throws PaginationException
        Generates a raw string of pre-MineDown-formatted text that when formatted will create the page menu.

        List formats and options from the ListOptions are applied to generate the list.

        Parameters:
        page - The page number to get
        Returns:
        A raw string of pre-MineDown-formatted text, representing the page menu.
        Throws:
        PaginationException - If the page number is out of bounds
      • getTotalPages

        public int getTotalPages()
        Returns the total number of pages
        Returns:
        The total number of pages
      • getPageJumperButtons

        @NotNull
        protected @NotNull java.lang.String getPageJumperButtons​(int page)