Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Account upgrade warning #2674

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading