From 9b8b9c442e51c471f85361f79341ce998f8da2eb Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 23 Mar 2023 14:37:48 +0100 Subject: Created CropType --- .../hannibal2/skyhanni/data/GardenCropMilestones.kt | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/data') diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt index dcdf4360d..ba0d8d863 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.CropMilestoneUpdateEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded @@ -31,16 +32,9 @@ class GardenCropMilestones { @SubscribeEvent fun onProfileJoin(event: ProfileJoinEvent) { if (cropCounter.isEmpty()) { - cropCounter["Wheat"] = 0 - cropCounter["Carrot"] = 0 - cropCounter["Potato"] = 0 - cropCounter["Pumpkin"] = 0 - cropCounter["Sugar Cane"] = 0 - cropCounter["Melon"] = 0 - cropCounter["Cactus"] = 0 - cropCounter["Cocoa Beans"] = 0 - cropCounter["Mushroom"] = 0 - cropCounter["Nether Wart"] = 0 + for (crop in CropType.values()) { + cropCounter[crop] = 0 + } } } @@ -50,6 +44,7 @@ class GardenCropMilestones { for ((_, stack) in event.inventoryItems) { val cropName = stack.name?.removeColor() ?: continue + val crop = CropType.getByName(cropName) ?: continue val lore = stack.getLore() var cropForTier = 0L @@ -70,7 +65,7 @@ class GardenCropMilestones { if (matcher.matches()) { val rawNumber = matcher.group(1) val overflow = rawNumber.formatNumber() - cropCounter[cropName] = cropForTier + overflow + cropCounter[crop] = cropForTier + overflow } next = false } @@ -81,7 +76,7 @@ class GardenCropMilestones { } companion object { - val cropCounter: MutableMap get() = SkyHanniMod.feature.hidden.gardenCropCounter + val cropCounter: MutableMap get() = SkyHanniMod.feature.hidden.gardenCropCounter fun getTierForCrops(crops: Long): Int { var tier = 0 -- cgit