From d56e3075c7d418e0004f072703e635e83e2a06cf Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 8 Dec 2023 16:21:41 +0100 Subject: code cleanup --- .../features/garden/NextJacobContestConfig.java | 21 ++++----------------- .../hannibal2/skyhanni/features/garden/CropType.kt | 2 ++ .../features/garden/GardenNextJacobContest.kt | 7 +------ 3 files changed, 7 insertions(+), 23 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/NextJacobContestConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/NextJacobContestConfig.java index 0f6f0be2f..2da4b7c42 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/NextJacobContestConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/NextJacobContestConfig.java @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.config.features.garden; import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.core.config.Position; +import at.hannibal2.skyhanni.features.garden.CropType; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; @@ -10,7 +11,6 @@ import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; import io.github.moulberry.moulconfig.annotations.ConfigOption; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class NextJacobContestConfig { @@ -62,23 +62,10 @@ public class NextJacobContestConfig { @Expose @ConfigOption( name = "Warn For", - desc = "Only Warn for these crops" + desc = "Only warn for these crops." ) - @ConfigEditorDraggableList( - exampleText = { - "Wheat", - "Carrot", - "Potato", - "Nether Wart", - "Pumpkin", - "Melon", - "Cocoa Beans", - "Sugar Cane", - "Cactus", - "Mushroom" - } - ) - public List warnFor = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); + @ConfigEditorDraggableList + public List warnFor = new ArrayList<>(CropType.getEntries()); @Expose public Position pos = new Position(-200, 10, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt index 41ef944ea..05abfe744 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt @@ -40,6 +40,8 @@ enum class CropType( val multiplier by lazy { if (this == SUGAR_CANE || this == CACTUS) 2 else 1 } + override fun toString(): String = cropName + companion object { fun getByNameOrNull(itemName: String): CropType? { if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") return MUSHROOM 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 e6f59fe88..d5d1881e2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -421,12 +421,7 @@ object GardenNextJacobContest { ) } - private fun warnForCrop(): Boolean { - for(crop in nextContestCrops) { - if (config.warnFor.contains(crop.ordinal)) return true - } - return false - } + private fun warnForCrop(): Boolean = nextContestCrops.any { it in config.warnFor } @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { -- cgit