Package com.jagrosh.jdautilities.menu
Class Paginator.Builder
java.lang.Object
com.jagrosh.jdautilities.menu.Menu.Builder<Paginator.Builder,Paginator>
com.jagrosh.jdautilities.menu.Paginator.Builder
- Enclosing class:
Paginator
The
Menu.Builder for
a Paginator.- Author:
- John Grosh
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds String items to the list of items to paginate.allowTextInput(boolean allowTextInput) Sets thePaginatorto allow a page number to be specified by a user via text.build()Builds thePaginatorwith this Builder.Clears the list of String items to paginate.getItems()Gets the String list of items to paginate.setBulkSkipNumber(int bulkSkipNumber) Sets thePaginator's bulk-skip function to skip multiple pages using alternate forward and backwardsSets theColorof theMessageEmbed.setColor(BiFunction<Integer, Integer, Color> colorBiFunction) Sets theColorof theMessageEmbed, relative to the total page number and the current page as determined by the providedBiFunction.setColumns(int columns) Sets the number of columns each page will have.setFinalAction(Consumer<net.dv8tion.jda.api.entities.Message> finalAction) Sets the String list of items to paginate.setItemsPerPage(int num) Sets the number of items that will appear on each page.setLeftRightText(String left, String right) Sets thePaginatorto traverse left or right when a provided text input is sent in the form of a Message to theGuildChannelthe menu is displayed in.Sets the text of theMessageto be displayed when thePaginatoris built.setText(BiFunction<Integer, Integer, String> textBiFunction) Sets the text of theMessageto be displayed relative to the total page number and the current page as determined by the providedBiFunction.showPageNumbers(boolean show) Sets whether or not the page number will be shown.useNumberedItems(boolean number) Sets whether or not the items will be automatically numbered.waitOnSinglePage(boolean wait) wrapPageEnds(boolean wrapPageEnds) Sets thePaginatorto wrap from the last page to the first when traversing right and visa versa from the left.Methods inherited from class com.jagrosh.jdautilities.menu.Menu.Builder
addRoles, addUsers, setEventWaiter, setRoles, setTimeout, setUsers
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
Builds thePaginatorwith this Builder.- Specified by:
buildin classMenu.Builder<Paginator.Builder,Paginator> - Returns:
- The Paginator built from this Builder.
- Throws:
IllegalArgumentException- If one of the following is violated:- No
EventWaiterwas set. - No items were set to paginate.
- No
-
setColor
Sets theColorof theMessageEmbed.- Parameters:
color- The Color of the MessageEmbed- Returns:
- This builder
-
setColor
Sets theColorof theMessageEmbed, relative to the total page number and the current page as determined by the providedBiFunction.
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
Sets the text of theMessageto be displayed when thePaginatoris 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
Sets the text of theMessageto be displayed relative to the total page number and the current page as determined by the providedBiFunction.
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
- Parameters:
finalAction- The Consumer action to perform if the Paginator times out- Returns:
- This builder
-
setColumns
Sets the number of columns each page will have.
By default this is 1.- Parameters:
columns- The number of columns- Returns:
- This builder
-
setItemsPerPage
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
Sets whether or not the page number will be shown.- Parameters:
show-trueif the page number should be shown,falseif it should not- Returns:
- This builder
-
useNumberedItems
Sets whether or not the items will be automatically numbered.- Parameters:
number-trueif the items should be numbered,falseif it should not- Returns:
- This builder
-
waitOnSinglePage
Sets whether thePaginatorwill instantly timeout, and possibly run a providedRunnable, if only a single slide is available to display.- Parameters:
wait-trueif the Paginator will still generate- Returns:
- This builder
-
clearItems
Clears the list of String items to paginate.- Returns:
- This builder
-
addItems
Adds String items to the list of items to paginate.- Parameters:
items- The String list of items to add- Returns:
- This builder
-
setItems
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
Gets the String list of items to paginate.
Useful when determining amount of items are being paginated.- Returns:
- the String list
-
setBulkSkipNumber
Sets thePaginator'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
Sets thePaginatorto wrap from the last page to the first when traversing right and visa versa from the left.- Parameters:
wrapPageEnds-trueto enable wrapping.- Returns:
- This builder
-
allowTextInput
Sets thePaginatorto 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, providenullfor one or both of the parameters of that method.- Parameters:
allowTextInput-trueif the Paginator will allow page-number text input- Returns:
- This builder
-
setLeftRightText
Sets thePaginatorto traverse left or right when a provided text input is sent in the form of a Message to theGuildChannelthe menu is displayed in.If one or both these parameters are provided
nullthis 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 leftright- The right text input, causes the Paginator to traverse one page right- Returns:
- This builder
-