Lukkit
Search…
Create a simple inv

Create a simple inventar

1
-- Create inventory
2
local title = "This is the inventory title"
3
local slots = 9
4
local inv = plugin.getServer():createInventory(nil, slots, title)
5
-- Open inventory for player
6
player:openInventory(inv)
Copied!
Make sure thah your slots number can be divided by 9 and is lower then 55 (max. Slots 54)
inv_simple

Set an item for the inventory

1
-- Import utils
2
local itemStack = import("org.bukkit.inventory.ItemStack")
3
local material = import("$.Material")
4
-- Create inventory
5
local title = "This is the inventory title"
6
local slots = 9
7
local inv = plugin.getServer():createInventory(nil, slots, title)
8
9
-- Create new item stack
10
local countOfItems = 1
11
local newItemStack = luajava.new(itemStack, material.GRASS, countOfItems, 0)
12
-- Set item to a slot
13
local setSlot = 0
14
inv:setItem(setSlot, newItemStack)
15
-- Open inventory for player
16
player:openInventory(inv)
Copied!
This code allows you to open an inventory with an grass block item in the first slot of the inventory
inv_with_item
Last modified 6mo ago