aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index bedbebc46..1433961d2 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -152,19 +152,20 @@ object ItemUtils {
return nbt.getCompoundTag("SkullOwner").getString("Id")
}
- fun ItemStack.getItemRarity(): Int {
- //todo make into an enum in future
+ fun ItemStack.getItemRarity() = getItemRarityOrNull() ?: error("item rarity not detected for item '$name'")
+
+ fun ItemStack.getItemRarityOrNull(): LorenzRarity? {
return when (this.getLore().lastOrNull()?.take(4)) {
- "§f§l" -> 0 // common
- "§a§l" -> 1 // uncommon
- "§9§l" -> 2 // rare
- "§5§l" -> 3 // epic
- "§6§l" -> 4 // legendary
- "§d§l" -> 5 // mythic
- "§b§l" -> 6 // divine
- "§4§l" -> 7 // supreme
- "§c§l" -> 8 // special/very special
- else -> -1 // unknown
+ "§f§l" -> LorenzRarity.COMMON
+ "§a§l" -> LorenzRarity.UNCOMMON
+ "§9§l" -> LorenzRarity.RARE
+ "§5§l" -> LorenzRarity.EPIC
+ "§6§l" -> LorenzRarity.LEGENDARY
+ "§d§l" -> LorenzRarity.MYTHIC
+ "§b§l" -> LorenzRarity.DIVINE
+ "§4§l" -> LorenzRarity.SUPREME
+ "§c§l" -> LorenzRarity.SPECIAL
+ else -> null
}
}