aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAlexia Luna <me@alexia.lol>2024-03-17 19:10:41 +0100
committerGitHub <noreply@github.com>2024-03-17 19:10:41 +0100
commit6e32cd257e2ff2274881df3d6db50d0e851dff0c (patch)
tree6b3a6f54a71e34ee4821eac1031679de5e7a5c85 /src/main/java
parent142496da0dd0142acb44232fbab0fc15b0ceb9da (diff)
downloadskyhanni-6e32cd257e2ff2274881df3d6db50d0e851dff0c.tar.gz
skyhanni-6e32cd257e2ff2274881df3d6db50d0e851dff0c.tar.bz2
skyhanni-6e32cd257e2ff2274881df3d6db50d0e851dff0c.zip
Improvement: Add delay after tool swap before warning about wrong speed (#840)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt17
1 files changed, 11 insertions, 6 deletions
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 e1a02630a..a057082ad 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
@@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isRancherSign
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
@@ -47,6 +48,7 @@ class GardenOptimalSpeed {
private var lastWarnTime = 0L
private var cropInHand: CropType? = null
private var rancherOverlayList: List<List<Any?>> = emptyList()
+ private var lastToolSwitch = SimpleTimeMark.farPast()
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
@@ -93,6 +95,7 @@ class GardenOptimalSpeed {
@SubscribeEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
+ lastToolSwitch = SimpleTimeMark.now()
cropInHand = event.crop
optimalSpeed = cropInHand?.getOptimalSpeed() ?: -1
}
@@ -138,13 +141,15 @@ class GardenOptimalSpeed {
text += " (§eCurrent: §f$currentSpeed"
if (sneaking) text += " §7[Sneaking]"
text += "§f)"
-
- if (config.showOnHUD) config.pos.renderString("§c$text", posLabel = "Garden Optimal Speed")
- if (sneaking && !sneakingPersistent) return
- warn()
- } else {
- if (config.showOnHUD) config.pos.renderString("§a$text", posLabel = "Garden Optimal Speed")
}
+
+ val recentlySwitchedTool = lastToolSwitch.passedSince() < 1.5.seconds
+ val recentlyStartedSneaking = sneaking && !sneakingPersistent
+
+ val colorCode = if (recentlySwitchedTool || recentlyStartedSneaking) "7" else if (optimalSpeed != currentSpeed) "c" else "a"
+
+ if (config.showOnHUD) config.pos.renderString("§$colorCode$text", posLabel = "Garden Optimal Speed")
+ if (optimalSpeed != currentSpeed && !recentlySwitchedTool && !recentlyStartedSneaking) warn()
}
private fun warn() {