diff options
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) } +} + |