VitalInventory

Defines an inventory menu within the Vital-Framework. An inventory menu is a GUI used to display information to a player, and process a player's inputs.

By default, the class will be a bean.

@VitalInventory.Info(
name = "MyInventory",
type = VitalInventory.Type.GENERIC_9X1,
background = Material.COBBLESTONE
)
public class MyInventory extends VitalInventory {
@Override
public void onUpdate() {
// This function is called when someone or something triggers an inventory update.
// It should not be used to set player-specific items, only global ones.
}

@Override
public void onUpdate(Player player) {
// This function is called when someone or something triggers an inventory update with a player.
// It should be used to set player-specific items, not global ones.
}

// ...
}

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
@Component
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class Info(val type: VitalInventory.Type, val name: String, val background: Material = Material.AIR)

Defines the info for a VitalInventory.

Link copied to clipboard

Defines the supported MenuTypes a VitalInventory can use.

Properties

Link copied to clipboard
val actions: MutableMap<UUID, MutableMap<Int, Consumer<InventoryClickEvent>>>
Link copied to clipboard
val background: ItemStack
Link copied to clipboard
open override val info: MutableMap<Class<out Annotation>, Annotation>
Link copied to clipboard
val items: MutableMap<UUID, MutableMap<Int, ItemStack?>>
Link copied to clipboard
val playerInventories: MutableMap<UUID, InventoryView>

Functions

Link copied to clipboard
open fun click(e: InventoryClickEvent)

Internal function to handle a InventoryClickEvent for this inventory. If the clicked item has an action attached to it via setItem, the action will be triggered.

Link copied to clipboard
open fun close(player: SpigotPlayer)

Closes this inventory for the given player. This function will clean up the state for this inventory and eventually call the onClose lifecycle function for the given player.

Link copied to clipboard
fun getActions(playerUniqueId: UUID): MutableMap<Int, Consumer<InventoryClickEvent>>

Gets all mapped actions for the given playerUniqueId. This function will never return null, even if the given playerUniqueId doesn't have this inventory open.

Link copied to clipboard
open fun <T : Annotation> getInfo(type: Class<T>): T
Link copied to clipboard
fun getInventory(playerUniqueId: UUID): InventoryView?

Gets the actual InventoryView for the given playerUniqueId. This function will return null if the given playerUniqueId doesn't have this inventory open.

Link copied to clipboard
fun getItems(playerUniqueId: UUID): MutableMap<Int, ItemStack?>

Gets all items for the given playerUniqueId. This function will never return null, even if the given playerUniqueId doesn't have this inventory open.

Link copied to clipboard

Checks if the given SpigotPlayer currently has this inventory open.

Link copied to clipboard
open fun open(player: SpigotPlayer, previousInventory: VitalInventory? = null)

Opens this inventory for the given player and updates it via update. If a previousInventory was given, clicking outside of this inventory view will open the previous inventory.

Link copied to clipboard
fun setItem(player: SpigotPlayer, slot: Int, item: ItemStack?, action: Consumer<InventoryClickEvent> = Consumer {})

Sets the given item in the slot for the inventory of the given player. Once the player opens this inventory, the actual InventoryView will be populated with all items set via this function. Additionally, an item may have an action attached to it.

Link copied to clipboard
fun update()

Updates this inventory for all players currently viewing it. Calling this function will call the onUpdate lifecycle function.

open fun update(player: SpigotPlayer)

Updates this inventory for the given player. All previously set items via setItem will be populated in the inventory for the given player. If the player doesn't have this inventory open, this function does nothing.