Lukkit
Search…
Create an advanced inv

Create an item with more information

1
-- Import utils
2
local itemStack = import("org.bukkit.inventory.ItemStack")
3
local javaArrayList = import("java.util.ArrayList")
4
local material = import("$.Material")
5
-- Create inventory
6
local title = "This is the inventory title"
7
local slots = 9
8
local inv = plugin.getServer():createInventory(nil, slots, title)
9
10
-- Create new item stack
11
local countOfItems = 1
12
local newItemStack = luajava.new(itemStack, material.GRASS, countOfItems, 0)
13
-- Get item meta from new item stack
14
local meta = newItemStack:getItemMeta()
15
-- Set new item text
16
meta:setDisplayName("WoW crazy item")
17
18
-- Set new lore to item
19
local description = {"WoW this is a cool", "description O.o"}
20
local list = luajava.new(javaArrayList)
21
for i = 1, #description do
22
list:add(description[i])
23
end
24
meta:setLore(list)
25
26
-- Set the new item meta
27
newItemStack:setItemMeta(meta)
28
-- Set item to a slot
29
local setSlot = 0
30
inv:setItem(setSlot, newItemStack)
31
-- Open inventory for player
32
player:openInventory(inv)
Copied!
This code allows you to set the item name and the lore text
inv_advanced
Last modified 6mo ago
Copy link