KPageInventoryImpl

class KPageInventoryImpl(owner: KInventoryHolder, val size: Int = 3*9, var looping: Boolean, var title: Component?) : BaseKInventoryImpl, KPageInventory

Constructors

Link copied to clipboard
constructor(owner: KInventoryHolder, size: Int = 3*9, looping: Boolean, title: Component?)

Properties

Link copied to clipboard

All animations Identifier maps to the animation

Link copied to clipboard
open override var content: MutableMap<Int, KItem>

Content of the container

Link copied to clipboard

The current animation if one is running

Link copied to clipboard
open override var formattedTitle: Component?

Formatted title given by the titleBuilder

Link copied to clipboard
open override var id: UUID

The unique ID of this identifiable

Link copied to clipboard
open override 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
open override 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
open override 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
open override 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
Link copied to clipboard

the length of a row in the inventory

Link copied to clipboard
open override var savePageWhenClosed: Boolean

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

Link copied to clipboard
val size: Int

of the content container, should be a multiple of the rowLength

Link copied to clipboard
open override var staticPages: MutableMap<String, KPage>

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
open override var title: Component?

Title of the inventory rendered in the bukkit inventory

Link copied to clipboard
open override 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
open override var views: MutableList<InventoryView>

Views which currently look at the inventory

Functions

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

Adds the animation

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

Adds a page to the current inventory

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

Adds a static page to this inventory

Link copied to clipboard
open override fun buildTitle(): Component?

Build a title for the inventory based on the given builder

Link copied to clipboard
open override fun clearInventory()

Clears the inventory from all items inside it

Link copied to clipboard
open override fun closed()

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

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

Returns all the items in the inventory which have been set

Link copied to clipboard
open override fun getKHolder(): KInventoryHolder

Returns the KInventoryHolder of this inventory

Link copied to clipboard
open override fun getPage(): KPage?
Link copied to clipboard
open override 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
open override fun getRowForItem(item: KItem): KRow?
Link copied to clipboard
open override fun getSlotForItem(item: KItem): Int
Link copied to clipboard
open override fun hasID(): Boolean
Link copied to clipboard
open override fun insertPage(index: Int, page: KPage)

Inserts the given page into the inventory at the given index

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

Whether the object is currently inside an animation

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

Checks whether the given inventory is the same inventory

Link copied to clipboard
open override fun isOpened(): Boolean
Link copied to clipboard
open override 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
open override 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
open override fun mainPage(init: KPage.() -> Unit): KPage

Main page builder

Link copied to clipboard
open override 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
open override 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
open override fun onClose(action: KInventory.() -> Unit)

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

Link copied to clipboard
open override 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
open override fun onOpen(action: KInventory.() -> Unit)

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

Link copied to clipboard
open override fun opened()

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

Link copied to clipboard
open override 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
open override fun removePage(page: KPage)

Removes the given space from the inventory

Link copied to clipboard
open override fun setCurrentIndexedPage()

Sets the page with the current index

Link copied to clipboard
open override fun setItem(slot: Int, item: KItem)

Sets the given item at the given position

open override fun setItem(row: Int, slot: Int, item: KItem)

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

Link copied to clipboard
open override 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
open override fun setPage(index: Int)

Sets the current page displayed in the inventory

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

Sets the given row at the given index

Link copied to clipboard
open override 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
open override fun startAnimation(animation: Animation<KInventory>)

Starts the given animation, but will not save it

open override 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
open override fun toBukkitInventory(): Inventory

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