diff options
author | Linnea Gräf <nea@nea.moe> | 2024-02-15 19:38:09 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-02-15 19:38:09 +0100 |
commit | edc72af6ec6055822d0deed8efe3c952cbf65026 (patch) | |
tree | 08e37cd85499fe6932c668e321b05c7e47f8f369 /src/main/kotlin/moe/nea/ledger/ItemUtil.kt | |
parent | aa8ca77ae239b9b6be140911524d70ba2b46c42d (diff) | |
download | LocalTransactionLedger-edc72af6ec6055822d0deed8efe3c952cbf65026.tar.gz LocalTransactionLedger-edc72af6ec6055822d0deed8efe3c952cbf65026.tar.bz2 LocalTransactionLedger-edc72af6ec6055822d0deed8efe3c952cbf65026.zip |
Add collect all support
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/ItemUtil.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/ItemUtil.kt | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/ItemUtil.kt b/src/main/kotlin/moe/nea/ledger/ItemUtil.kt index 365c37e..7157386 100644 --- a/src/main/kotlin/moe/nea/ledger/ItemUtil.kt +++ b/src/main/kotlin/moe/nea/ledger/ItemUtil.kt @@ -11,3 +11,11 @@ fun ItemStack.getInternalId(): String? { return id.takeIf { it.isNotBlank() } } + +fun ItemStack.getLore(): List<String> { + val nbt = this.tagCompound ?: NBTTagCompound() + val extraAttributes = nbt.getCompoundTag("display") + val lore = extraAttributes.getTagList("Lore", 8) + return (0 until lore.tagCount()).map { lore.getStringTagAt(it) } +} + |