item
you can make custom item stacks using Katton.item(...) and manipulate their display names, lore, custom tags, enchantments, or clone them
properties
item.setName(text) //sets the custom display name of the item stack
methods
item.setLore(lines)
item.setTag(key, value)
item.getTag(key)
item.enchant(name, level)
item.clone()
item.dye(r,g,b)
setLore
sets the lore description lines on the item stack
item.setLore(lines)
example
wand.setLore(["&7Right click to leap forward!", "&7Cooldown: none"])
setTag
applies custom data stored directly on the item's metadata
item.setTag(key, value)
Note
tag values are always stored and read back as strings
example
val wand = Katton.item("stick")
wand.setName("&aLeap Wand")
wand.setTag("ability", "leap_wand") // mark this specific item
sender.give(wand)
getTag
reads custom data stored directly on the item's metadata
item.getTag(key)
Note
getTag returns null if the tag was never set on that item
example
@Katton.listen("player_rightclick")
function onLeap(event) {
val item = event.item
if (item != null && item.getTag("ability") == "leap_wand") { // this is one of our wands, not a random item
event.player.launchForward(1.8, 0.65)
}
}
enchant
applies a vanilla enchantment to the item stack
item.enchant(name, level)
Note
passing an unknown enchantment name throws a runtime error
example
val sword = Katton.item("diamond_sword")
sword.enchant("sharpness", 5)
sword.enchant("unbreaking", 3)
clone
creates a duplicate copy of the item stack with all its current properties and custom tags preserved
item.clone()
example
val original = Katton.item("stick")
original.setName("&aOriginal")
val copy = original.clone()
copy.setName("&bCopy")
dye
dyes a leather armor item
item.dye(r,g,b)
example
val leather = Katton.item("leather_chestplate")
leather.dye(245, 73, 39)