Items.kt

Branches > main > bda016e > files / src / main / kotlin / net / bowmap / mc / items / Items.kt

package net.bowmap.mc.items

import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.NamedTextColor
import net.kyori.adventure.text.format.TextDecoration
import org.bukkit.Material
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.ItemMeta

val BUG: ItemStack = updateMeta(ItemStack(Material.STONE_BUTTON)) {
  it.itemName(Component.text("Bug"))
  it.lore(
    listOf(
      Component.text("You encountered something that hasn't been implemented yet,", NamedTextColor.GRAY)
                .decoration(TextDecoration.ITALIC, false),
      Component.text("so you get this instead.", NamedTextColor.GRAY)
               .decoration(TextDecoration.ITALIC, false)
    )
  )
}

val TUTORIAL_BOW: ItemStack = updateMeta(ItemStack(Material.BOW)) {
  it.itemName(Component.text("Tutorial Bow"))
  // Rarity
  // Lore:
  // Less powerful than a skeleton's bow.
  // You'll want to find one.
}

// TODO just use a lambda lol
fun updateMeta(item: ItemStack, f: (ItemMeta) -> Unit): ItemStack {
  val newItem = item.clone()
  val meta = newItem.itemMeta
  f(meta)
  newItem.setItemMeta(meta)
  return newItem
}

// data class Texture(val material: Material, val customModelData: Int? = null)
//
// data class BowmapItem(
//   val material: Material,
//   val name: Component,
//   val amount: Int = 1,
//   val maxStackSize: Int = 1,
//   val texture: Texture = Texture(material = material)
// ) {
//   init {
//     require(material == texture.material)
//   }
// }