aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
index 937299d22..2531c7cb1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
@@ -36,7 +36,10 @@ import javax.swing.JButton
import javax.swing.JFrame
import javax.swing.JOptionPane
import javax.swing.UIManager
+import kotlin.time.Duration.Companion.days
import kotlin.time.Duration.Companion.seconds
+import kotlin.time.DurationUnit
+import kotlin.time.toDuration
object GardenNextJacobContest {
private var dispatcher = Dispatchers.IO
@@ -292,21 +295,15 @@ object GardenNextJacobContest {
nextContest: FarmingContest,
list: MutableList<Any>,
): MutableList<Any> {
- var boostedCrop: CropType? = null
- outer@ for (line in TabListData.getTabList()) {
- val lineStripped = line.removeColor().trim()
- if (lineStripped.startsWith("☘ ")) {
- for (crop in nextContest.crops) {
- if (line.removeColor().trim() == "☘ ${crop.cropName}") {
- boostedCrop = crop
- break@outer
- }
- }
- break
- }
+ var duration = nextContest.endTime - System.currentTimeMillis()
+ val durationObj = duration.toDuration(DurationUnit.MILLISECONDS)
+ if (durationObj > 4.days) {
+ list.add("§New SB Year, wait a bit.")
+ return list
}
- var duration = nextContest.endTime - System.currentTimeMillis()
+ val boostedCrop = calculateBoostedCrop(nextContest)
+
if (duration < contestDuration) {
list.add("§aActive: ")
} else {
@@ -325,6 +322,20 @@ object GardenNextJacobContest {
return list
}
+ private fun calculateBoostedCrop(nextContest: FarmingContest): CropType? {
+ for (line in TabListData.getTabList()) {
+ val lineStripped = line.removeColor().trim()
+ if (!lineStripped.startsWith("☘ ")) continue
+ for (crop in nextContest.crops) {
+ if (line.removeColor().trim() == "☘ ${crop.cropName}") {
+ return crop
+ }
+ }
+ }
+
+ return null
+ }
+
private fun warn(timeInMillis: Long, crops: List<CropType>, boostedCrop: CropType?) {
if (!config.warn) return
if (config.warnTime <= timeInMillis / 1000) return