From 704b90b4a25a88cb3ad33fa77a1b9423caaf472d Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Thu, 4 Apr 2024 20:30:46 +0200 Subject: Feature: No Bits Warning (#1286) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/data/BitsAPI.kt | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/data') diff --git a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt index 65af5b8bd..54131f4bf 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.FameRanks.getFameRankByNameOrNull +import at.hannibal2.skyhanni.events.BitsUpdateEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent @@ -117,8 +118,8 @@ object BitsAPI { if (amount > bits) { bitsToClaim -= amount - bits ChatUtils.debug("You have gained §3${amount - bits} Bits §7according to the scoreboard!") + sendEvent() } - bits = amount return } @@ -133,12 +134,14 @@ object BitsAPI { bitsFromFameRankUpChatPattern.matchMatcher(message) { val amount = group("amount").formatInt() bitsToClaim += amount + sendEvent() return } boosterCookieAte.matchMatcher(message) { bitsToClaim += (defaultcookiebits * (currentFameRank?.bitsMultiplier ?: return)).toInt() + sendEvent() return } @@ -161,7 +164,11 @@ object BitsAPI { for (line in cookieStack.getLore()) { bitsAvailableMenuPattern.matchMatcher(line) { - bitsToClaim = group("toClaim").formatInt() + val amount = group("toClaim").formatInt() + if (bitsToClaim != amount) { + bitsToClaim = amount + sendEvent() + } return } @@ -207,7 +214,12 @@ object BitsAPI { line@ for (line in bitsStack.getLore()) { bitsAvailableMenuPattern.matchMatcher(line) { - bitsToClaim = group("toClaim").formatInt() + val amount = group("toClaim").formatInt() + if (amount != bitsToClaim) { + bitsToClaim = amount + sendEvent() + } + continue@line } @@ -215,6 +227,10 @@ object BitsAPI { } } + private fun sendEvent() { + BitsUpdateEvent(bits, bitsToClaim).postAndCatch() + } + fun isEnabled() = LorenzUtils.inSkyBlock && profileStorage != null class FameRankNotFoundException(rank: String) : Exception("FameRank not found: $rank") -- cgit