NextDevv's Docs Help

GuiPage

class GuiPage { private val content: MutableList<ItemStack> = mutableListOf() fun addItem(itemStack: ItemStack): GuiPage { content.add(itemStack) return this } fun addItem(itemStack: ItemStack, index: Int): GuiPage { content.add(index, itemStack) return this } fun removeItem(index: Int): GuiPage { content.removeAt(index) return this } fun removeItem(itemStack: ItemStack): GuiPage { content.remove(itemStack) return this } fun filterContent(predicate: (ItemStack) -> Boolean): GuiPage { content.filter(predicate) return this } fun getContent(): MutableList<ItemStack> { return content } }

Description & Properties

The GuiPage class is used to represent a single page within a GUI. It contains a list of item stacks that are displayed on the page. The class has the following properties and methods:

  • content: A list of ItemStack objects that represent the items displayed on the page.

  • addItem(itemStack: ItemStack): Adds an item stack to the page and returns the GuiPage object.

  • addItem(itemStack: ItemStack, index: Int): Adds an item stack to the page at a specific index and returns the GuiPage object.

  • removeItem(index: Int): Removes an item stack from the page at the specified index and returns the GuiPage object.

  • removeItem(itemStack: ItemStack): Removes a specific item stack from the page and returns the GuiPage object.

  • filterContent(predicate: (ItemStack) -> Boolean): Filters the content of the page based on a predicate and returns the GuiPage object.

  • getContent(): MutableList<ItemStack>: Returns the list of item stacks on the page.

Example

You can create a GuiPage object, add item stacks to it, and manipulate its content using the provided methods. The content property of the GuiPage class stores the item stacks that are displayed on the page.

Here is an example of how to create a GuiPage object in Kotlin:

val guiPage = GuiPage() guiPage.addItem(ItemStack(Material.DIAMOND_SWORD)) guiPage.addItem(ItemStack(Material.GOLDEN_APPLE)) guiPage.addItem(ItemStack(Material.DIAMOND_CHESTPLATE), 1) guiPage.removeItem(1) guiPage.removeItem(ItemStack(Material.GOLDEN_APPLE)) val content = guiPage.getContent()

In this example, we create a GuiPage object and add item stacks to it. We then remove an item stack at a specific index and remove a specific item stack from the page. Finally, we retrieve the content of the page as a list of item stacks for further processing or display in a GUI.

Summary

The GuiPage class is a fundamental building block for creating paginated GUIs with multiple pages. By managing the content of each page separately, you can easily organize and display items in a structured manner within your GUIs. The GuiPage class provides methods to add, remove, and filter item stacks on a page, allowing you to customize the content dynamically based on user interactions or other events.

Last modified: 03 July 2024