Pages
Description & Properties
The Pages
class is used to manage multiple GuiPage
objects within a GUI. It has the following properties and methods:
pages
: A list ofGuiPage
objects that represent the pages in the GUI.addPage(guiPage: GuiPage): Pages
: Adds aGuiPage
to the list of pages.addPage(guiPage: GuiPage, index: Int): Pages
: Adds aGuiPage
at the specified index in the list of pages.removePage(index: Int): Pages
: Removes theGuiPage
at the specified index from the list of pages.removePage(guiPage: GuiPage): Pages
: Removes the specifiedGuiPage
from the list of pages.filterPages(predicate: (GuiPage) -> Boolean): Pages
: Filters the list of pages based on the given predicate.builder(): Builder
: Returns aBuilder
object to create and configure aPages
object.Builder
: A nested class that provides methods to configure and build aPages
object.pages
: A list ofGuiPage
objects to be added to thePages
object.maxPerPages
: The maximum number of items per page.autoCreatePages(itemStacks: List<ItemStack): Builder
: Automatically creates pages based on a list of item stacks, splitting them into pages based on themaxPerPages
value.setMaxPerPages(maxPerPages: Int): Builder
: Sets the maximum number of items per page.build(): Pages
: Builds and returns aPages
object with the configured settings.
Example
You can use the Pages
class to manage multiple GuiPage
objects within a GUI and automatically split a list of item stacks into pages. This allows you to create paginated GUIs with a fixed number of items per page.
Here is an example of how to use the Pages
class in Kotlin:
In this example, we create a Pages
object and use a builder to configure it. We set the maximum number of items per page to 2 and automatically split a list of item stacks into pages. The resulting Pages
object contains the paginated content based on the specified settings.
You can then use the Pages
object to manage and display multiple pages of content within a GUI, allowing players to navigate through the pages to view different items or information.
Summary
The Pages
class provides a convenient way to manage multiple GuiPage
objects within a GUI and create paginated interfaces for displaying content. By organizing items into pages and allowing players to navigate between them, you can enhance the user experience and present information in a structured and accessible manner.