diff options
author | Empa <42304516+ItsEmpa@users.noreply.github.com> | 2024-04-04 20:30:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-04 20:30:46 +0200 |
commit | 704b90b4a25a88cb3ad33fa77a1b9423caaf472d (patch) | |
tree | f53caad245fdff5f733c80cc28b04bb8c25bcce2 /src/main/java/at/hannibal2/skyhanni/data | |
parent | d48cf0126f9c163dd85c860004f658167912c85c (diff) | |
download | skyhanni-704b90b4a25a88cb3ad33fa77a1b9423caaf472d.tar.gz skyhanni-704b90b4a25a88cb3ad33fa77a1b9423caaf472d.tar.bz2 skyhanni-704b90b4a25a88cb3ad33fa77a1b9423caaf472d.zip |
Feature: No Bits Warning (#1286)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt | 22 |
1 files changed, 19 insertions, 3 deletions
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") |