diff options
author | Brandon <brandon.wamboldt@gmail.com> | 2023-09-08 06:35:43 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-08 11:35:43 +0200 |
commit | 62ebd2a830490ab921c94819e1d24ff4494f00ec (patch) | |
tree | fef05e8e2bd5d72821690cc95236e169a0e62887 /src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt | |
parent | c0ca23e0027b8a70b3e81b4db176eee02b79b1ca (diff) | |
download | skyhanni-62ebd2a830490ab921c94819e1d24ff4494f00ec.tar.gz skyhanni-62ebd2a830490ab921c94819e1d24ff4494f00ec.tar.bz2 skyhanni-62ebd2a830490ab921c94819e1d24ff4494f00ec.zip |
Feature: Outline dropped items (#449)
Add feature to outline dropped items #449
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 25 |
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 } } |