aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-13 20:06:59 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-13 20:06:59 +0200
commit1097c46e471a81e41849287b64b0cb4b37a778c3 (patch)
treeee4bc23c6f4cedac730ebe7260ab8a58f2ad2772 /src/main/java/at/hannibal2
parentb9af0f20131d686cfa2ac77ce4838af40944b64e (diff)
downloadskyhanni-1097c46e471a81e41849287b64b0cb4b37a778c3.tar.gz
skyhanni-1097c46e471a81e41849287b64b0cb4b37a778c3.tar.bz2
skyhanni-1097c46e471a81e41849287b64b0cb4b37a778c3.zip
crop.getSpeed() is not nullable
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt7
6 files changed, 12 insertions, 25 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt
index fd8d592fd..da777f020 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt
@@ -44,7 +44,6 @@ object GardenCropTimeCommand {
val (baseId, baseAmount) = NEUItems.getMultiplier(internalName)
val baseName = NEUItems.getItemStack(baseId).name!!
val crop = CropType.getByName(baseName.removeColor())
- val speed = crop.getSpeed()
val fullAmount = baseAmount.toLong() * amount.toLong()
val text = if (baseAmount == 1) {
@@ -53,7 +52,8 @@ object GardenCropTimeCommand {
"§e${amount.addSeparators()}x $itemName §7(§e${fullAmount.addSeparators()}x $baseName§7)"
}
- if (speed == -1) {
+ val speed = crop.getSpeed()
+ if (speed == null) {
map["$text §cNo speed data!"] = -1
} else {
val missingTimeSeconds = fullAmount / speed
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
index cbb34b623..4c6bb23f8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
@@ -242,8 +242,7 @@ object CropMoneyDisplay {
}
}
- var speed = crop.getSpeed().toDouble()
- if (speed == -1.0) continue
+ var speed = crop.getSpeed()?.toDouble() ?: continue
val isCurrent = crop == GardenAPI.getCurrentlyFarmedCrop()
val debug = isCurrent && showCalculation
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt
index d0be7c7a5..a71edb381 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt
@@ -209,11 +209,9 @@ class EliteFarmingWeight {
}
private fun updateWeightPerSecond(crop: CropType, before: Double, after: Double, diff: Int) {
- val speed = crop.getSpeed()
- if (speed != -1) {
- val weightDiff = (after - before) * 1000
- weightPerSecond = weightDiff / diff * speed / 1000
- }
+ val speed = crop.getSpeed() ?: return
+ val weightDiff = (after - before) * 1000
+ weightPerSecond = weightDiff / diff * speed / 1000
}
private fun getExactWeight(): Double {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt
index 360819e30..19bd4936f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt
@@ -26,8 +26,7 @@ class GardenBestCropTime {
fun updateTimeTillNextCrop() {
for (crop in CropType.values()) {
- val speed = crop.getSpeed()
- if (speed == -1) continue
+ val speed = crop.getSpeed() ?: continue
val counter = crop.getCounter()
val currentTier = GardenCropMilestones.getTierForCrops(counter)
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 2ff5706b2..af797ba2e 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
@@ -10,7 +10,6 @@ import at.hannibal2.skyhanni.events.GardenToolChangeEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
-import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.concurrent.fixedRateTimer
@@ -114,15 +113,10 @@ object GardenCropSpeed {
fun isEnabled() = GardenAPI.inGarden()
- fun CropType.getSpeed(): Int {
+ fun CropType.getSpeed(): Int? {
val speed = cropsPerSecond[this]
- if (speed != null) return speed
-
- val message = "Set speed for $this to -1!"
- println(message)
- LorenzUtils.debug(message)
- setSpeed(-1)
- return -1
+ if (speed == -1) return null
+ return speed
}
fun CropType.setSpeed(speed: Int) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index 14d0920c4..6c51b51fa 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -320,17 +320,14 @@ class GardenVisitorFeatures {
val multiplier = NEUItems.getMultiplier(internalName)
val rawName = NEUItems.getItemStack(multiplier.first).name?.removeColor() ?: continue
getByNameOrNull(rawName)?.let {
- val speed = it.getSpeed()
val cropAmount = multiplier.second.toLong() * amount
val formatAmount = LorenzUtils.formatInteger(cropAmount)
val formatName = "§e$formatAmount§7x ${it.cropName} "
- val formatSpeed = if (speed != -1) {
+ val formatSpeed = it.getSpeed()?.let { speed ->
val missingTimeSeconds = cropAmount / speed
val duration = TimeUtils.formatDuration(missingTimeSeconds * 1000)
"in §b$duration"
- } else {
- "§cno speed data!"
- }
+ } ?: "§cno speed data!"
itemsWithSpeedCounter++
list.add(i + itemsWithSpeedCounter, " §7- $formatName($formatSpeed§7)")
}