Package net.william278.paginedown
Class PaginatedList
- java.lang.Object
-
- net.william278.paginedown.PaginatedList
-
public class PaginatedList extends java.lang.Object
A class used to generateMineDown
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
ListOptions
to modify the format of each element, including shortcuts for modifying a theme color. Once you have created aPaginatedList
object using the staticget(items, options)
, you can easily generate aMineDown
formatted chat menu for a given page using thegetPage()
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 aMineDown
formatted message to be sent to a player of the paginated list for the nearest specified page that existsde.themoep.minedown.adventure.MineDown
getPage(int page)
Returns aMineDown
formatted message to be sent to a player of the paginated list for the specified pageprotected @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 pagesstatic @NotNull PaginatedList
of(@NotNull java.util.List<java.lang.String> items)
Create a newPaginatedList
from aList
of itemsstatic @NotNull PaginatedList
of(@NotNull java.util.List<java.lang.String> items, @NotNull ListOptions options)
Create a newPaginatedList
from aList
of items
-
-
-
Method Detail
-
of
@NotNull public static @NotNull PaginatedList of(@NotNull @NotNull java.util.List<java.lang.String> items)
Create a newPaginatedList
from aList
of items- Parameters:
items
- TheList
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 newPaginatedList
from aList
of items- Parameters:
items
- TheList
of items to paginateoptions
- TheListOptions
to use for generating list pages- Returns:
- A new
PaginatedList
-
getNearestValidPage
@NotNull public @NotNull de.themoep.minedown.adventure.MineDown getNearestValidPage(int page)
Returns aMineDown
formatted message to be sent to a player of the paginated list for the nearest specified page that existsList 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 aMineDown
formatted message to be sent to a player of the paginated list for the specified pageList 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)
-
-