InventoryApi
Services.get("InventoryApi")
Overview
API Reference
createItem()
createItem()Creates an ItemStack from a JavaScript object.
const item = inventoryApi.createItem({
id: "minecraft:diamond",
name: "§b§lExample Item",
lore: [
"§7This is an example",
"§7Created via InventoryApi"
],
amount: 1
})Parameters:
data(Object) Item configuration object:
id
String
Minecraft item ID
name
String
Display name (supports color codes)
lore
String[]
Item lore
amount
Number (optional)
Item amount (default: 1)
Returns:
ItemStack⇒org.bukkit.inventory.ItemStack
constructInventory()
constructInventory()Creates an interactive inventory UI.
Parameters:
type(String)"single"⇒ Standard single chest inventory"double"⇒ Standard double chest inventorytitle(String) Inventory title (supports color codes)
Returns:
InventoryUI⇒ Managed inventory interface
InventoryUI API
The object returned by constructInventory() exposes the following methods.
setSlot()
setSlot()Sets an item in a specific slot.
Parameters:
slot(Number)item(ItemStack)
copy()
copy()Creates a deep copy of the inventory UI.
Returns:
InventoryUI
show()
show()Opens the inventory for a player.
Parameters:
player(Player)
hide()
hide()Closes the inventory for a player.
Parameters:
player(Player)
destroy()
destroy()Destroys the inventory and unregisters all listeners.
Always call destroy() when the inventory is no longer needed.
onLeftClick()
onLeftClick()Registers a left-click handler.
Returns: (function handler)
player⇒Playerslot⇒Numberevent⇒InventoryClickEvent
onRightClick()
onRightClick()Registers a right-click handler.
Returns: (function handler)
player⇒Playerslot⇒Numberevent⇒InventoryClickEvent
onItemPlaced()
onItemPlaced()Called when an item is placed into the inventory.
Returns: (function handler)
player⇒Playerslot⇒Numberevent⇒InventoryClickEvent
onClosed()
onClosed()Called when the inventory is closed.
Example:
Last updated
Was this helpful?