item

creating an item

Katton.item(material, amount = 1)

material is a case insensitive vanilla paper material name

val sword = Katton.item("diamond_sword")
val arrows = Katton.item("arrow", 16)
val stick = Katton.item("STICK") // case doesnt matter

an unknown material name will cause a runtime error naming exactly what was wrong

methods

item.setName(text)
item.setLore(lines)
item.setTag(key, value)
item.getTag(key)
item.enchant(name, level)
item.clone()

setName

val wand = Katton.item("stick")
wand.setName("&aLeap Wand")

setLore

wand.setLore(["&7Right click to leap forward!", "&7Cooldown: none"])

takes a list of strings, one per line

setTag / getTag

tags let you mark an item as "special"

val wand = Katton.item("stick")
wand.setName("&aLeap Wand")
wand.setTag("ability", "leap_wand") // mark this specific item

sender.give(wand)

then, elsewhere, check for that tag before doing something special:

@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(horizontal = 1.8, vertical = 0.65)
    }
}

getTag returns null if the tag was never set. always check with != null (or compare directly like above, since null == "leap_wand" is just false) before relying on it

you can also store more than one tag on the same item:

val sword = Katton.item("diamond_sword")
sword.setTag("weapon_id", "starter_sword")
sword.setTag("damage_bonus", "5")

tag values are always stored and read back as strings

enchant

val sword = Katton.item("diamond_sword")
sword.enchant("sharpness", 5)
sword.enchant("unbreaking", 3)

level must be between 1 and 5. unknown enchantment names are a runtime error

clone

val original = Katton.item("stick")
original.setName("&aOriginal")

val copy = original.clone()
copy.setName("&bCopy")