diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-01-22 21:33:28 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-01-22 21:33:28 +0100 |
commit | 8e351f8e0b5dc961138bb2bdfb901ac31cfced52 (patch) | |
tree | 94a286c156135f1b56a017e6e6e1b03e8cace092 | |
parent | fc090691c5da91ad828b0ae712f7af306ddfd197 (diff) | |
download | skyhanni-8e351f8e0b5dc961138bb2bdfb901ac31cfced52.tar.gz skyhanni-8e351f8e0b5dc961138bb2bdfb901ac31cfced52.tar.bz2 skyhanni-8e351f8e0b5dc961138bb2bdfb901ac31cfced52.zip |
code cleanup
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt index 72dc37621..e5df0f58a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt @@ -7,13 +7,14 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.TimeUtils +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class JacobContestStatsSummary { private val config get() = GardenAPI.config private var blocksBroken = 0 - private var startTime = 0L + private var startTime = SimpleTimeMark.farPast() @SubscribeEvent fun onBlockClick(event: CropClickEvent) { @@ -32,16 +33,15 @@ class JacobContestStatsSummary { when (event.phase) { FarmingContestPhase.START -> { LorenzUtils.chat("Started tracking your Jacob Contest Blocks Per Second!") - startTime = System.currentTimeMillis() + startTime = SimpleTimeMark.now() } FarmingContestPhase.STOP -> { - val duration = System.currentTimeMillis() - startTime - val durationInSeconds = duration.toDouble() / 1000 - val blocksPerSecond = (blocksBroken.toDouble() / durationInSeconds).round(2) + val duration = startTime.passedSince() + val blocksPerSecond = (blocksBroken.toDouble() / duration.inWholeSeconds).round(2) val cropName = event.crop.cropName LorenzUtils.chat("Stats for $cropName Contest:") - val time = TimeUtils.formatDuration(duration - 999) + val time = duration.format() LorenzUtils.chat("§7Blocks Broken in total: §e${blocksBroken.addSeparators()}") val color = getBlocksPerSecondColor(blocksPerSecond) LorenzUtils.chat("§7Average Blocks Per Second: $color$blocksPerSecond") @@ -50,7 +50,7 @@ class JacobContestStatsSummary { FarmingContestPhase.CHANGE -> { LorenzUtils.chat("You changed the crop during the contest, resetting the Blocks Per Second calculation..") - startTime = System.currentTimeMillis() + startTime = SimpleTimeMark.now() } } blocksBroken = 0 |