From 973e95ea5d9c0bba381548c5af04fd2ced713925 Mon Sep 17 00:00:00 2001 From: Contrabass <83555891+Contrabass26@users.noreply.github.com> Date: Tue, 25 Jul 2023 15:04:41 +0100 Subject: Merge pull request #99 * Fixed calendar reading going above 100 percent --- .../features/garden/GardenNextJacobContest.kt | 36 ++++++++++++---------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'src/main') 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 2a5a3bbf1..3a7e2bc15 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -112,24 +112,26 @@ class GardenNextJacobContest { } } - for (item in items) { - val lore = item.getLore() - if (!lore.any { it.contains("§6§eJacob's Farming Contest") }) continue - - val name = item.name ?: continue - val matcherDay = patternDay.matcher(name) - if (!matcherDay.matches()) continue - - val day = matcherDay.group("day").toInt() - val startTime = SkyBlockTime(year, month, day).toMillis() - val crops = mutableListOf() - for (line in lore) { - val matcherCrop = patternCrop.matcher(line) - if (!matcherCrop.matches()) continue - crops.add(CropType.getByName(matcherCrop.group("crop"))) + if (contests.size < maxContestsPerYear) { + for (item in items) { + val lore = item.getLore() + if (!lore.any { it.contains("§6§eJacob's Farming Contest") }) continue + + val name = item.name ?: continue + val matcherDay = patternDay.matcher(name) + if (!matcherDay.matches()) continue + + val day = matcherDay.group("day").toInt() + val startTime = SkyBlockTime(year, month, day).toMillis() + val crops = mutableListOf() + for (line in lore) { + val matcherCrop = patternCrop.matcher(line) + if (!matcherCrop.matches()) continue + crops.add(CropType.getByName(matcherCrop.group("crop"))) + } + val contest = FarmingContest(startTime + contestDuration, crops) + contests[startTime] = contest } - val contest = FarmingContest(startTime + contestDuration, crops) - contests[startTime] = contest } update() -- cgit