aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/ledger/ItemUtil.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/ItemUtil.kt')
-rw-r--r--src/main/kotlin/moe/nea/ledger/ItemUtil.kt10
1 files changed, 10 insertions, 0 deletions
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<String, Int> {
+ val enchantments = getExtraAttributes().getCompoundTag("enchantments")
+ return enchantments.keySet.associateWith { enchantments.getInteger(it) }
+}
+
class PetInfo {
var type: String? = null
var tier: String? = null