diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-23 15:17:01 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-23 15:17:01 +0100 |
commit | afb4dae8eda1403079d73480dd3621d5e361f21f (patch) | |
tree | 5006d3c96b4f29709e4602913460f9bda05eb992 /src/main/java/at/hannibal2/skyhanni | |
parent | d341829214683e1dfb9009da1120f3dae290a8f1 (diff) | |
download | skyhanni-afb4dae8eda1403079d73480dd3621d5e361f21f.tar.gz skyhanni-afb4dae8eda1403079d73480dd3621d5e361f21f.tar.bz2 skyhanni-afb4dae8eda1403079d73480dd3621d5e361f21f.zip |
Added CropType.setSpeed
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
3 files changed, 13 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index 45cb2f0ab..8ca84f684 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -72,12 +72,12 @@ class GardenAPI { } companion object { - fun inGarden() = LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.GARDEN - var toolInHand: String? = null - val cropsPerSecond: MutableMap<CropType, Int> get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond + private val cropsPerSecond: MutableMap<CropType, Int> get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond var cropInHand: CropType? = null + fun inGarden() = LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.GARDEN + fun getCropTypeFromItem(item: ItemStack?): CropType? { val internalName = item?.getInternalName() ?: return null return CropType.values().firstOrNull { internalName.startsWith(it.toolName) } @@ -102,6 +102,10 @@ class GardenAPI { } fun CropType.getSpeed() = cropsPerSecond[this]!! + + fun CropType.setSpeed(speed: Int) { + cropsPerSecond[this] = speed + } fun itemNameToCropName(itemName: String): CropType? { if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt index 7e2619be1..2205d9c8e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter +import at.hannibal2.skyhanni.features.garden.GardenAPI.Companion.getSpeed import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import at.hannibal2.skyhanni.utils.TimeUtils import java.util.* @@ -13,7 +14,7 @@ class GardenBestCropTime { private val config get() = SkyHanniMod.feature.garden fun drawBestDisplay(currentCrop: CropType?) { - if (timeTillNextCrop.size < GardenAPI.cropsPerSecond.size) { + if (timeTillNextCrop.size < CropType.values().size) { updateTimeTillNextCrop() } @@ -67,7 +68,8 @@ class GardenBestCropTime { private fun getGardenExpForTier(gardenLevel: Int) = if (gardenLevel > 30) 300 else gardenLevel * 10 fun updateTimeTillNextCrop() { - for ((crop, speed) in GardenAPI.cropsPerSecond) { + for (crop in CropType.values()) { + val speed = crop.getSpeed() if (speed == -1) continue val counter = crop.getCounter() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt index c5108be32..89461e076 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter import at.hannibal2.skyhanni.data.SendTitleHelper import at.hannibal2.skyhanni.events.* +import at.hannibal2.skyhanni.features.garden.GardenAPI.Companion.setSpeed import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SoundUtils.playSound @@ -191,7 +192,7 @@ class GardenCropMilestoneDisplay { } if (averageSpeedPerSecond != 0) { - GardenAPI.cropsPerSecond[crop] = averageSpeedPerSecond + crop.setSpeed(averageSpeedPerSecond) val missing = need - have val missingTimeSeconds = missing / averageSpeedPerSecond val millis = missingTimeSeconds * 1000 |