diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt index 5bdcffa31a69..13745c840d54 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.garden.farming.FarmingContestEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc @@ -98,7 +99,19 @@ object FarmingContestAPI { private fun readCurrentCrop(): CropType? { val line = ScoreboardData.sidebarLinesFormatted.nextAfter("§eJacob's Contest") ?: return null return sidebarCropPattern.matchMatcher(line) { - CropType.getByName(group("crop")) + val cropName = group("crop") + try { + CropType.getByName(cropName) + } catch (e: IllegalStateException) { + ScoreboardData.sidebarLinesFormatted + ErrorManager.logErrorWithData( + e, "Farming contest read current crop failed", + "cropName" to cropName, + "line" to line, + "sidebarLinesFormatted" to ScoreboardData.sidebarLinesFormatted, + ) + null + } } }