aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/fame
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-10-06 13:28:54 +0200
committerGitHub <noreply@github.com>2024-10-06 13:28:54 +0200
commit9dd04711a4e3ca577ad3b41891aaa5eb7c403197 (patch)
tree66340c70abb8d4310e8a577b0bed7df3be60c984 /src/main/java/at/hannibal2/skyhanni/features/fame
parenta07ad3ee5b80d214fa62583817309f1ddc1c2c64 (diff)
downloadskyhanni-9dd04711a4e3ca577ad3b41891aaa5eb7c403197.tar.gz
skyhanni-9dd04711a4e3ca577ad3b41891aaa5eb7c403197.tar.bz2
skyhanni-9dd04711a4e3ca577ad3b41891aaa5eb7c403197.zip
Fix: Account upgrade warning (#2674)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fame')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt
index d22151c1b..b55aa8f11 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt
@@ -96,6 +96,36 @@ object UpgradeReminder {
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
if (!LorenzUtils.inSkyBlock) return
inInventory = event.inventoryName == "Community Shop"
+ if (!inInventory) return
+
+ if (currentProfileUpgrade == null && currentAccountUpgrade == null) return
+ detectWrongAccountUpgradeData(event.inventoryItems)
+ }
+
+ private fun detectWrongAccountUpgradeData(items: Map<Int, ItemStack>) {
+ val hasProfileUpgrade = foundActiveUpgrade(items, 27..35)
+ if (!hasProfileUpgrade && currentProfileUpgrade != null) {
+ ChatUtils.chat("§eRemoved invalid Profile Upgrade information.")
+ currentProfileUpgrade = null
+ }
+
+ val hasAccountUpgrade = foundActiveUpgrade(items, 36..44)
+ if (!hasAccountUpgrade && currentAccountUpgrade != null) {
+ ChatUtils.chat("§eRemoved invalid Account Upgrade information.")
+ currentAccountUpgrade = null
+ }
+ }
+
+ private fun foundActiveUpgrade(items: Map<Int, ItemStack>, slots: IntRange): Boolean {
+ for (slot in slots) {
+ val item = items[slot] ?: continue
+ val isUpgrading = item.getLore().any { it == "§aCurrently upgrading!" }
+ val isDone = item.getLore().any { it == "§cClick to claim!" }
+ val isReadyForUpgrade = item.getLore().any { it == "§eClick to start upgrade!" }
+ if (isUpgrading || isDone) return true
+ if (isReadyForUpgrade) return false
+ }
+ return false
}
@SubscribeEvent