aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-01 23:14:12 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-01 23:14:12 +0200
commitce765217f8f2f4732e5d55323f0bf2f58f7df2e3 (patch)
treeb44ad5763b702f9914b7e8d86bcb01aaa476da3a /src
parent62fd05099a4f0b1cbc88368f0f99cf38ef8c5875 (diff)
downloadskyhanni-ce765217f8f2f4732e5d55323f0bf2f58f7df2e3.tar.gz
skyhanni-ce765217f8f2f4732e5d55323f0bf2f58f7df2e3.tar.bz2
skyhanni-ce765217f8f2f4732e5d55323f0bf2f58f7df2e3.zip
Fixed crashes and config resets because of averageBlocksPerSecond is 'not a number'
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt6
2 files changed, 5 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
index f35f08c96..e32f1d899 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
@@ -18,6 +18,7 @@ class ConfigManager {
companion object {
val gson = GsonBuilder().setPrettyPrinting()
.excludeFieldsWithoutExposeAnnotation()
+ .serializeSpecialFloatingPointValues()
.registerTypeAdapterFactory(PropertyTypeAdapterFactory())
.create()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt
index 0124d75ca..2ff5706b2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt
@@ -68,7 +68,7 @@ object GardenCropSpeed {
if (blocksBroken == 0) {
if (blocksSpeedList.size == 0) return
- secondsStopped ++
+ secondsStopped++
} else {
if (secondsStopped >= config.blocksBrokenResetTime) {
resetSpeed()
@@ -82,7 +82,9 @@ object GardenCropSpeed {
blocksSpeedList.removeFirst()
blocksSpeedList.add(blocksBroken)
}
- averageBlocksPerSecond = blocksSpeedList.dropLast(1).average()
+ averageBlocksPerSecond = if (blocksSpeedList.size > 1) {
+ blocksSpeedList.dropLast(1).average()
+ } else 0.0
GardenAPI.getCurrentlyFarmedCrop()?.let {
latestBlocksPerSecond[it] = averageBlocksPerSecond
}