From 2c448cf20f20936c3d4c83ff29c0bf043fe6394f Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sun, 21 Apr 2024 23:00:12 +0200 Subject: Fix: Fixed Bits Gained Chat Messages randomly being send (#1503) --- src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 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 d400959c0..c580e00d5 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt @@ -7,7 +7,6 @@ import at.hannibal2.skyhanni.events.BitsUpdateEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent -import at.hannibal2.skyhanni.features.misc.NoBitsWarning.sendBitsGainChatMessage import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -153,10 +152,10 @@ object BitsAPI { if (amount == bits) return if (amount > bits) { - bitsAvailable -= amount - bits - sendBitsGainChatMessage(amount - bits) + val difference = amount - bits + bitsAvailable -= difference bits = amount - sendBitsGainEvent() + sendBitsGainEvent(difference) } else { bits = amount sendBitsSpentEvent() @@ -228,7 +227,6 @@ object BitsAPI { val difference = bits - bitsAvailable if (difference > 0) { - sendBitsGainChatMessage(difference) bits += difference } } @@ -308,7 +306,7 @@ object BitsAPI { fun hasCookieBuff() = cookieBuffTime?.isInFuture() ?: false - private fun sendBitsGainEvent() = BitsUpdateEvent.BitsGain(bits, bitsAvailable).postAndCatch() + private fun sendBitsGainEvent(difference: Int) = BitsUpdateEvent.BitsGain(bits, bitsAvailable, difference).postAndCatch() private fun sendBitsSpentEvent() = BitsUpdateEvent.BitsSpent(bits, bitsAvailable).postAndCatch() private fun sendBitsAvailableGainedEvent() = BitsUpdateEvent.BitsAvailableGained(bits, bitsAvailable).postAndCatch() -- cgit