diff options
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java | 4 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java | 6 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/items/ItemStars.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/items/CrimsonArmorTier.kt) | 99 |
3 files changed, 72 insertions, 37 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 7784dffb3..cf4580ef0 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -21,9 +21,9 @@ import at.hannibal2.skyhanni.features.dungeon.*; import at.hannibal2.skyhanni.features.fishing.SeaCreatureManager; import at.hannibal2.skyhanni.features.fishing.SeaCreatureMessageShortener; import at.hannibal2.skyhanni.features.fishing.TrophyFishMessages; -import at.hannibal2.skyhanni.features.items.CrimsonArmorTier; import at.hannibal2.skyhanni.features.items.HideNotClickableItems; import at.hannibal2.skyhanni.features.items.ItemDisplayOverlayFeatures; +import at.hannibal2.skyhanni.features.items.ItemStars; import at.hannibal2.skyhanni.features.items.abilitycooldown.ItemAbilityCooldown; import at.hannibal2.skyhanni.features.nether.ashfang.AshfangFreezeCooldown; import at.hannibal2.skyhanni.features.nether.ashfang.AshfangGravityOrbs; @@ -94,7 +94,7 @@ public class SkyHanniMod { registerEvent(new AshfangNextResetCooldown()); registerEvent(new SummoningSoulsName()); registerEvent(new AshfangGravityOrbs()); - registerEvent(new CrimsonArmorTier()); + registerEvent(new ItemStars()); registerEvent(new RealTime()); Commands.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java index a756d1725..e2231a9d1 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java @@ -44,8 +44,8 @@ public class Inventory { public boolean anvilCombineHelper = false; @Expose - @ConfigOption(name = "Crimson Armor Stars", - desc = "Show a compact star count in the item name for the Aurora, Crimson, Terror and Fervor armor") + @ConfigOption(name = "Item Stars", + desc = "Show a compact star count in the item name for all items") @ConfigEditorBoolean - public boolean crimsonArmorStars = false; + public boolean itemStars = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/items/CrimsonArmorTier.kt b/src/main/java/at/hannibal2/skyhanni/features/items/ItemStars.kt index 4bcc5051b..0131801e2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/items/CrimsonArmorTier.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/items/ItemStars.kt @@ -11,7 +11,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern -class CrimsonArmorTier { +class ItemStars { private val armorNames = mutableListOf<String>() private val tiers = mutableMapOf<String, Int>() @@ -21,19 +21,21 @@ class CrimsonArmorTier { @SubscribeEvent(priority = EventPriority.LOWEST) fun onTooltip(event: ItemTooltipEvent) { if (!LorenzUtils.inSkyblock) return - if (!SkyHanniMod.feature.inventory.crimsonArmorStars) return val stack = event.itemStack ?: return if (stack.stackSize != 1) return - val number = getCrimsonNumber(stack.name ?: return) + if (!SkyHanniMod.feature.inventory.itemStars) return - if (number > 0) { - var name = stack.name!! + val itemName = stack.name ?: return + val stars = getStars(itemName) + + if (stars > 0) { + var name = itemName while (STAR_FIND_PATCHER.matcher(name).matches()) { name = name.replaceFirst("§.✪".toRegex(), "") } name = name.trim() - event.toolTip[0] = "$name §c$number✪" + event.toolTip[0] = "$name §c$stars✪" } } @@ -66,7 +68,7 @@ class CrimsonArmorTier { val stack = event.stack ?: return if (stack.stackSize != 1) return - val number = getCrimsonNumber(stack.name ?: return) + val number = getCrimsonStars(stack.name ?: return) val stackTip = if (number == -1) "" else number.toString() if (stackTip.isNotEmpty()) { @@ -84,32 +86,65 @@ class CrimsonArmorTier { } } - private fun getCrimsonNumber(fullName: String): Int { - var name = fullName - if (armorNames.any { name.contains(it) } && armorParts.any { name.contains(it) }) { - var gold = 0 - var pink = 0 - var aqua = 0 - while (name.contains("§6✪")) { - name = name.replaceFirst("§6✪", "") - gold++ - } - while (name.contains("§d✪")) { - name = name.replaceFirst("§d✪", "") - pink++ - } - while (name.contains("§b✪")) { - name = name.replaceFirst("§b✪", "") - aqua++ - } - return (tiers.entries.find { name.contains(it.key) }?.value ?: 0) + if (aqua > 0) { - 10 + aqua - } else if (pink > 0) { - 5 + pink - } else { - gold - } + private fun getStars(name: String): Int { + val stars = getCrimsonStars(name) + if (stars != -1) { + return stars + } + + return getOtherStars(name) + } + + private fun getCrimsonStars(name: String): Int { + if (!armorNames.any { name.contains(it) } || !armorParts.any { name.contains(it) }) { + return -1 + } + var name1 = name + var gold = 0 + var pink = 0 + var aqua = 0 + while (name1.contains("§6✪")) { + name1 = name1.replaceFirst("§6✪", "") + gold++ + } + while (name1.contains("§d✪")) { + name1 = name1.replaceFirst("§d✪", "") + pink++ } + while (name1.contains("§b✪")) { + name1 = name1.replaceFirst("§b✪", "") + aqua++ + } + return (tiers.entries.find { name1.contains(it.key) }?.value ?: 0) + if (aqua > 0) { + 10 + aqua + } else if (pink > 0) { + 5 + pink + } else { + gold + } + } + + private fun getOtherStars(originalName: String): Int { + var name = originalName + + var gold = 0 + var red = 0 + while (name.contains("§6✪")) { + name = name.replaceFirst("§6✪", "") + gold++ + } + while (name.contains("§c✪")) { + name = name.replaceFirst("§6✪", "") + red++ + } + while (name.contains("§d✪")) { + name = name.replaceFirst("§6✪", "") + red++ + } + + if (red > 0) return 5 + red + if (gold > 0) return gold + return -1 } }
\ No newline at end of file |