aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-18 11:55:34 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-18 11:55:34 +0200
commit26c7d6e52a87cecba7da9af7975363cf798eb110 (patch)
tree4639fb3a6f9d88727ef5a3d7723ca09a0e6788a1
parent80f2a9dd281550145fca9e0e2bd6ef121f3c758f (diff)
downloadskyhanni-26c7d6e52a87cecba7da9af7975363cf798eb110.tar.gz
skyhanni-26c7d6e52a87cecba7da9af7975363cf798eb110.tar.bz2
skyhanni-26c7d6e52a87cecba7da9af7975363cf798eb110.zip
Fixed bug that 5 seconds till next milestone warning spams indefinitely
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt26
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt2
2 files changed, 17 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt
index 5d98bd05d..3186d78b3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt
@@ -173,17 +173,7 @@ object GardenCropMilestoneDisplay {
GardenBestCropTime.timeTillNextCrop[crop] = millis
val biggestUnit = TimeUnit.values()[config.cropMilestoneHighestTimeFormat.get()]
val duration = TimeUtils.formatDuration(millis, biggestUnit)
- if (config.cropMilestoneWarnClose) {
- if (millis < 5_900) {
- if (System.currentTimeMillis() > lastPlaySoundTime + 1_000) {
- lastPlaySoundTime = System.currentTimeMillis()
- SoundUtils.playBeepSound()
- }
- if (!needsInventory) {
- TitleUtils.sendTitle("§b${crop.cropName} $nextTier in $duration", 1_500)
- }
- }
- }
+ tryWarn(millis, "§b${crop.cropName} $nextTier in $duration")
val speedText = "§7In §b$duration"
lineMap[3] = Collections.singletonList(speedText)
GardenAPI.itemInHand?.let {
@@ -208,6 +198,20 @@ object GardenCropMilestoneDisplay {
return formatDisplay(lineMap)
}
+ private fun tryWarn(millis: Long, title: String) {
+ if (!config.cropMilestoneWarnClose) return
+ if (GardenCropSpeed.lastBrokenTime + 500 <= System.currentTimeMillis()) return
+ if (millis > 5_900) return
+
+ if (System.currentTimeMillis() > lastPlaySoundTime + 1_000) {
+ lastPlaySoundTime = System.currentTimeMillis()
+ SoundUtils.playBeepSound()
+ }
+ if (!needsInventory) {
+ TitleUtils.sendTitle(title, 1_500)
+ }
+ }
+
private fun formatDisplay(lineMap: HashMap<Int, List<Any>>): MutableList<List<Any>> {
val newList = mutableListOf<List<Any>>()
for (index in config.cropMilestoneText) {
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 3c61691ef..7903c2199 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
@@ -19,6 +19,7 @@ object GardenCropSpeed {
private val latestBlocksPerSecond: MutableMap<CropType, Double>? get() = GardenAPI.config?.latestBlocksPerSecond
var lastBrokenCrop: CropType? = null
+ var lastBrokenTime = 0L
var averageBlocksPerSecond = 0.0
@@ -62,6 +63,7 @@ object GardenCropSpeed {
if (event.clickType != ClickType.LEFT_CLICK) return
lastBrokenCrop = event.crop
+ lastBrokenTime = System.currentTimeMillis()
blocksBroken++
}