aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-05-26 23:02:48 +1000
committerGitHub <noreply@github.com>2024-05-26 15:02:48 +0200
commitf67af16eacb6cdf3598183d473f072d123ef8a25 (patch)
tree62d11d0f5191d48eee31a630a0b054baeb89a509 /src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt
parent29657e24412baa7be9a1681593593368f92de26f (diff)
downloadskyhanni-f67af16eacb6cdf3598183d473f072d123ef8a25.tar.gz
skyhanni-f67af16eacb6cdf3598183d473f072d123ef8a25.tar.bz2
skyhanni-f67af16eacb6cdf3598183d473f072d123ef8a25.zip
Backend: Convert stuff to SimpleTimeMark (#1777)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt
index 4c0d47614..e09eb11d7 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt
@@ -7,9 +7,11 @@ import at.hannibal2.skyhanni.events.ScoreboardChangeEvent
import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble
import at.hannibal2.skyhanni.utils.NumberUtil.million
import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.seconds
object PurseAPI {
private val patternGroup = RepoPattern.group("data.purse")
@@ -22,13 +24,13 @@ object PurseAPI {
"Piggy: (?<coins>.*)"
)
- private var inventoryCloseTime = 0L
+ private var inventoryCloseTime = SimpleTimeMark.farPast()
var currentPurse = 0.0
private set
@SubscribeEvent
fun onInventoryClose(event: InventoryCloseEvent) {
- inventoryCloseTime = System.currentTimeMillis()
+ inventoryCloseTime = SimpleTimeMark.now()
}
@SubscribeEvent
@@ -55,15 +57,13 @@ object PurseAPI {
}
if (Minecraft.getMinecraft().currentScreen == null) {
- val timeDiff = System.currentTimeMillis() - inventoryCloseTime
- if (timeDiff > 2_000) {
+ if (inventoryCloseTime.passedSince() > 2.seconds) {
return PurseChangeCause.GAIN_MOB_KILL
}
}
return PurseChangeCause.GAIN_UNKNOWN
} else {
- val timeDiff = System.currentTimeMillis() - SlayerAPI.questStartTime
- if (timeDiff < 1500) {
+ if (SlayerAPI.questStartTime.passedSince() < 1.5.seconds) {
return PurseChangeCause.LOSE_SLAYER_QUEST_STARTED
}