From 62ebd2a830490ab921c94819e1d24ff4494f00ec Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 8 Sep 2023 06:35:43 -0300 Subject: Feature: Outline dropped items (#449) Add feature to outline dropped items #449 --- .../java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt') 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 } } -- cgit