-- Create inventorylocal title ="This is the inventory title"local slots =9local inv = plugin.getServer():createInventory(nil, slots, title)-- Open inventory for playerplayer:openInventory(inv)
Make sure thah your slots number can be divided by 9 and is lower then 55 (max. Slots 54)
Set an item for the inventory
-- Import utilslocal itemStack = import("org.bukkit.inventory.ItemStack")local material = import("$.Material")-- Create inventorylocal title ="This is the inventory title"local slots =9local inv = plugin.getServer():createInventory(nil, slots, title)-- Create new item stacklocal countOfItems =1local newItemStack = luajava.new(itemStack, material.GRASS, countOfItems, 0)-- Set item to a slotlocal setSlot =0inv:setItem(setSlot, newItemStack)-- Open inventory for playerplayer:openInventory(inv)
This code allows you to open an inventory with an grass block item in the first slot of the inventory