aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-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++
}