KPageInventory

Models an inventory which support a pagination system

Works by saving the given pages and displaying them when reached

Author

Devin

Since

1.0.0

See also

Inheritors

Properties

Link copied to clipboard

All animations Identifier maps to the animation

Link copied to clipboard
abstract val content: MutableMap<Int, KItem>

Content of the container

Link copied to clipboard

The current animation if one is running

Link copied to clipboard
abstract var formattedTitle: Component?

Formatted title given by the titleBuilder

Link copied to clipboard
abstract var id: UUID

The unique ID of this identifiable

Link copied to clipboard
abstract var inventories: MutableList<Inventory>

Client side inventory instances

Link copied to clipboard

Sets whether the items can be clicked while the inventory is inside an animation

Link copied to clipboard
abstract var looping: Boolean

Whether the inventory should loop when the last page is reached If true will loop back to the first page when going to the next page on the last page

Link copied to clipboard
abstract var mainPage: KPage?

Is the first page to display when the inventory is opened. If null then no page will be displayed

Link copied to clipboard

Animation which will be played when the inventory is opened

Link copied to clipboard
abstract var pages: MutableList<KPage>

List of the pages of this inventory. Index of the item is also the index of the page

Link copied to clipboard

Whether the current page index should be saved when the inventory is closed

Link copied to clipboard

Static pages are used for pages which should not be in the standard pagination, but serve as a static content display page. So in the normal page cycle these pages won't show Pages will be identified by the given identifier

Link copied to clipboard
abstract var title: Component?

Title of the inventory rendered in the bukkit inventory

Link copied to clipboard
abstract var titleBuilder: (KPage, KPageInventory) -> Component?

If supplied this function is used to build the title for the inventory. When the page switches, this function will be called with the current page

Link copied to clipboard
abstract var views: MutableList<InventoryView>

Views which currently look at the inventory

Functions

Link copied to clipboard
abstract fun addAnimation(identifier: String, animation: Animation<KInventory>)

Adds the animation

Link copied to clipboard
abstract fun addPage(page: KPage)
abstract fun addPage(init: KPage.() -> Unit): KPage

Adds a page to the current inventory

Link copied to clipboard
abstract fun addStaticPage(identifier: String, page: KPage)
abstract fun addStaticPage(identifier: String, init: KPage.() -> Unit): KPage

Adds a static page to this inventory

Link copied to clipboard
abstract fun buildTitle(): Component?

Build a title for the inventory based on the given builder

Link copied to clipboard
abstract fun clearInventory()

Clears the inventory from all items inside it

Link copied to clipboard
abstract fun closed()

Sets the inventory to closed Should be called when the inventory has been closed.

Link copied to clipboard
abstract fun getItems(): Map<Int, KItem>

Returns all the items in the inventory which have been set

Link copied to clipboard

Returns the KInventoryHolder of this inventory

Link copied to clipboard
abstract fun getPage(): KPage?
Link copied to clipboard
abstract fun getRowFor(index: Int): KRow

Gets the row for the given index This will create a new row for the returned value

Link copied to clipboard
abstract fun getRowForItem(item: KItem): KRow?
Link copied to clipboard
abstract fun getSlotForItem(item: KItem): Int
Link copied to clipboard
abstract fun hasID(): Boolean
Link copied to clipboard
abstract fun insertPage(index: Int, page: KPage)

Inserts the given page into the inventory at the given index

Link copied to clipboard
abstract override fun isAnimating(): Boolean

Whether the object is currently inside an animation

Link copied to clipboard
abstract fun isEqual(inventory: Inventory): Boolean

Checks whether the given inventory is the same inventory

Link copied to clipboard
abstract fun isOpened(): Boolean
Link copied to clipboard
abstract fun isPrivate(): Boolean

Checks whether the inventory is private. Private indicated that only one player at a time can open the same reference to a KInventory

Link copied to clipboard
abstract fun itemClicked(item: ItemStack, player: Player, event: InventoryClickEvent)

Notifies the inventory that the given item has been clicked by the given player

Link copied to clipboard
abstract fun mainPage(init: KPage.() -> Unit): KPage

Main page builder

Link copied to clipboard
abstract fun nextPage()

Moves to the next page in the inventory If looping is enabled will loop back to the first page when end is reached

Link copied to clipboard
abstract fun notifyParent(kPage: KPage)

Util function to notify this inventory to rebuild the current page. Used when a page is changed, and needs to be updated in the parent inventory.

Link copied to clipboard
abstract fun onClose(action: KInventory.() -> Unit)

Executed when the inventory is closed To catch this the bukkit event is used

Link copied to clipboard
abstract fun onItemClicked(action: KInventory.(item: ItemStack, player: Player, event: InventoryClickEvent) -> Unit)

Executes the passed function, when a bukkit org.bukkit.inventory.ItemStack is clicked

Link copied to clipboard
abstract fun onOpen(action: KInventory.() -> Unit)

Executed when the inventory is opened To catch this the bukkit event is used

Link copied to clipboard
abstract fun opened()

Sets the inventory to opened Should be called when the inventory has been opened.

Link copied to clipboard
abstract fun previousPage()

Moves to the previous page in the inventory If looping is enabled will loop back to the last page when end is reached

Link copied to clipboard
abstract fun removePage(page: KPage)

Removes the given space from the inventory

Link copied to clipboard
abstract fun setCurrentIndexedPage()

Sets the page with the current index

Link copied to clipboard
abstract fun setItem(row: Int, slot: Int, item: KItem)

Sets the given item relative to the slot of the given row

abstract override fun setItem(slot: Int, value: KItem)

Sets the item relative to the current page, respecting the header and the footer If a header is set, the rows will be shifted by the header row. If a footer is set, the slots inside the last row are not accessible

Link copied to clipboard
abstract fun setItemOverride(slot: Int, kItem: KItem)

Sets the item to the absolut slot in the inventory, overriding the already existing item. This function can be used to override header and footer of the page

Link copied to clipboard
abstract fun setPage(index: Int)

Sets the current page displayed in the inventory

Link copied to clipboard
abstract fun setRow(index: Int, row: KRow)

Sets the given row at the given index

Link copied to clipboard
abstract fun setStaticPage(identifier: String)

Set the current page to the given static page The current index will be saved To get back to the indexed pages use

Link copied to clipboard
abstract fun startAnimation(animation: Animation<KInventory>)

Starts the given animation, but will not save it

abstract fun startAnimation(identifier: String)

Starts the animation with the given identifier

Link copied to clipboard
abstract fun swapRow(row: KRow, otherRow: KRow)

Swaps two rows in an inventory

abstract fun swapRow(index: Int, otherIndex: Int)

Swaps two rows based on their index

Link copied to clipboard
abstract fun toBukkitInventory(): Inventory

Constructs the bukkit inventory from this KInventory with the current set content