From 0ca988c907c7e8e26029f59cc098e6be5e008ee5 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sat, 7 Dec 2024 22:30:51 +0100 Subject: feat: Add dungeon chest loot detection --- src/main/kotlin/moe/nea/ledger/ItemUtil.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/main/kotlin/moe/nea/ledger/ItemUtil.kt') diff --git a/src/main/kotlin/moe/nea/ledger/ItemUtil.kt b/src/main/kotlin/moe/nea/ledger/ItemUtil.kt index 38c2b50..cadcb66 100644 --- a/src/main/kotlin/moe/nea/ledger/ItemUtil.kt +++ b/src/main/kotlin/moe/nea/ledger/ItemUtil.kt @@ -16,9 +16,19 @@ fun ItemStack.getInternalId(): ItemId? { if (id == "PET") { id = getPetId() ?: id } + if (id == "ENCHANTED_BOOK") { + id = getEnchanments().entries.singleOrNull()?.let { + "${it.key};${it.value}".uppercase() + } + } return id?.let(::ItemId) } +fun ItemStack.getEnchanments(): Map { + val enchantments = getExtraAttributes().getCompoundTag("enchantments") + return enchantments.keySet.associateWith { enchantments.getInteger(it) } +} + class PetInfo { var type: String? = null var tier: String? = null -- cgit