diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-05 15:16:07 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-05 15:16:07 +0100 |
commit | 4750fec1fe3a3cb2a748df627c8d2343b6fd969d (patch) | |
tree | c6fc283f79555f6ccfb57cf15278e1655e05e9db /src/main/java/at/hannibal2/skyhanni/features/garden | |
parent | deadca74501e95551f5e1665ebbfd1d6fa620b19 (diff) | |
download | skyhanni-4750fec1fe3a3cb2a748df627c8d2343b6fd969d.tar.gz skyhanni-4750fec1fe3a3cb2a748df627c8d2343b6fd969d.tar.bz2 skyhanni-4750fec1fe3a3cb2a748df627c8d2343b6fd969d.zip |
hide wrong new jacob contest times around new year, created calculateBoostedCrop()
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt | 37 |
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 |