aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authoralexia <me@alexia.lol>2023-12-09 22:09:19 +0100
committerGitHub <noreply@github.com>2023-12-09 22:09:19 +0100
commit786d4f53e85b654994cea911362db21f14503ead (patch)
tree437c138808c6b4b9b1519afe538da11c743f543c /src/main/java/at
parent5dd949398d70bc38fc90829ced65bd538cffddf2 (diff)
downloadskyhanni-786d4f53e85b654994cea911362db21f14503ead.tar.gz
skyhanni-786d4f53e85b654994cea911362db21f14503ead.tar.bz2
skyhanni-786d4f53e85b654994cea911362db21f14503ead.zip
Allow showing optimal speed warning without HUD (#784)
Allow showing optimal speed warning without HUD. #784
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt12
3 files changed, 8 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
index d375cad61..a113286fe 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
@@ -9,7 +9,7 @@ import com.google.gson.JsonPrimitive
object ConfigUpdaterMigrator {
val logger = LorenzLogger("ConfigMigration")
- const val CONFIG_VERSION = 13
+ const val CONFIG_VERSION = 14
fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? {
if (chain.isEmpty()) return this
if (this !is JsonObject) return null
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java
index 385d7907f..672f1f21e 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java
@@ -9,11 +9,11 @@ import io.github.moulberry.moulconfig.annotations.ConfigOption;
public class OptimalSpeedConfig {
@Expose
- @ConfigOption(name = "Enabled", desc = "Show the optimal speed for your current tool in the hand.\n" +
+ @ConfigOption(name = "Show on HUD", desc = "Show the optimal speed for your current tool in the hand.\n" +
"(Thanks MelonKingDE for the default values).")
@ConfigEditorBoolean
@FeatureToggle
- public boolean enabled = true;
+ public boolean showOnHUD = true;
@Expose
@ConfigOption(name = "Warning Title", desc = "Warn via title when you don't have the optimal speed.")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
index 201b1bc7e..8c55bcd28 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
@@ -60,9 +60,7 @@ class GardenOptimalSpeed {
@SubscribeEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
cropInHand = event.crop
- if (isEnabled()) {
- optimalSpeed = cropInHand.let { it?.getOptimalSpeed() ?: -1 }
- }
+ optimalSpeed = cropInHand.let { it?.getOptimalSpeed() ?: -1 }
}
private fun CropType.getOptimalSpeed() = when (this) {
@@ -80,7 +78,7 @@ class GardenOptimalSpeed {
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
- if (!isEnabled()) return
+ if (!GardenAPI.inGarden()) return
if (optimalSpeed == -1) return
@@ -88,10 +86,10 @@ class GardenOptimalSpeed {
val text = "Optimal Speed: §f$optimalSpeed"
if (optimalSpeed != currentSpeed) {
- config.pos.renderString("§c$text", posLabel = "Garden Optimal Speed")
+ if (config.showOnHUD) config.pos.renderString("§c$text", posLabel = "Garden Optimal Speed")
warn()
} else {
- config.pos.renderString("§a$text", posLabel = "Garden Optimal Speed")
+ if (config.showOnHUD) config.pos.renderString("§a$text", posLabel = "Garden Optimal Speed")
}
}
@@ -109,7 +107,6 @@ class GardenOptimalSpeed {
}
private fun isRancherOverlayEnabled() = GardenAPI.inGarden() && config.signEnabled
- private fun isEnabled() = GardenAPI.inGarden() && config.enabled
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
@@ -128,5 +125,6 @@ class GardenOptimalSpeed {
event.move(3, "garden.optimalSpeedCustom.sugarCane", "garden.optimalSpeeds.customSpeed.sugarCane")
event.move(3, "garden.optimalSpeedCustom.cactus", "garden.optimalSpeeds.customSpeed.cactus")
event.move(3, "garden.optimalSpeedCustom.mushroom", "garden.optimalSpeeds.customSpeed.mushroom")
+ event.move(14, "garden.optimalSpeeds.enabled", "garden.optimalSpeeds.showOnHUD")
}
}