aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt7
3 files changed, 9 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
index a488ef6dd..b854c6f7b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
@@ -22,7 +22,6 @@ import at.hannibal2.skyhanni.utils.TimeUtils.format
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.concurrent.fixedRateTimer
import kotlin.time.Duration
-import kotlin.time.Duration.Companion.INFINITE
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds
import kotlin.time.DurationUnit
@@ -142,7 +141,7 @@ class GardenVisitorTimer {
millis -= sinceLastTimerUpdate
}
- if (lastMillis == INFINITE) {
+ if (lastMillis == Duration.INFINITE) {
LorenzUtils.chat("§c[SkyHanni] Found Visitor Timer bug, reset value (lastMillis was infinite).")
lastMillis = 0.seconds
}
@@ -185,7 +184,10 @@ class GardenVisitorTimer {
fun onWorldChange(event: LorenzWorldChangeEvent) {
lastVisitors = -1
GardenAPI.storage?.nextSixthVisitorArrival?.let {
- sixthVisitorArrivalTime = it.asTimeMark()
+ val badTime = Duration.INFINITE.inWholeMilliseconds
+ if (it != badTime && it != -9223370336633802065) {
+ sixthVisitorArrivalTime = it.asTimeMark()
+ }
}
sixthVisitorReady = false
lastMillis = sixthVisitorArrivalTime.timeUntil()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 2e71ab2fa..967f183f6 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -133,9 +133,9 @@ object LorenzUtils {
var multiplier = 1.0
repeat(decimals) { multiplier *= 10 }
val result = kotlin.math.round(this * multiplier) / multiplier
- val a = result.toString()
- val b = toString()
- return if (a.length > b.length) this else result.toFloat()
+ val a = result.toString().length
+ val b = toString().length
+ return if (a > b) this else result.toFloat()
}
// TODO replace all calls with regex
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt b/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt
index eebcc5f06..3e30f300c 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt
@@ -7,8 +7,6 @@ import kotlin.time.Duration.Companion.milliseconds
@JvmInline
value class SimpleTimeMark(private val millis: Long) {
-// operator fun plus(other: SimpleTimeMark) =
-// (millis + other.millis).milliseconds
operator fun minus(other: SimpleTimeMark) =
(millis - other.millis).milliseconds
@@ -18,10 +16,7 @@ value class SimpleTimeMark(private val millis: Long) {
operator fun minus(other: Duration) = plus(-other)
-// operator fun minus(other: Duration) =
-// SimpleTimeMark(millis - other.inWholeMilliseconds)
-
- fun passedSince() = if (millis == 0L) Duration.INFINITE else now() - this
+ fun passedSince() = now() - this
fun timeUntil() = -passedSince()