From d60e47a53690d8b337f9f08b893741c3581e4356 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 2 Apr 2023 14:05:02 +0200 Subject: Fixed garden visitor time needed display not working with mushroom items --- .../at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt | 2 +- .../java/at/hannibal2/skyhanni/features/garden/CropType.kt | 10 +++++++++- .../java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt | 8 -------- .../skyhanni/features/garden/GardenVisitorFeatures.kt | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt index bfc20a7cd..a09102033 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt @@ -202,7 +202,7 @@ class CropMoneyDisplay { val (newId, amount) = NEUItems.getMultiplier(internalName) if (amount < 10) continue val itemName = NEUItems.getItemStack(newId).name?.removeColor() ?: continue - val crop = GardenAPI.itemNameToCropName(itemName) + val crop = CropType.getByItemName(itemName) crop?.let { multipliers[internalName] = amount cropNames[internalName] = it 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 d81702ffd..d83399c77 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt @@ -21,9 +21,17 @@ enum class CropType(val cropName: String, val toolName: String, iconSupplier: () val icon by lazy { iconSupplier() } companion object { - fun getByName(name: String) = values().firstOrNull { it.cropName == name } + fun getByName(cropName: String) = values().firstOrNull { it.cropName == cropName } // TODO find better name for this method fun getByNameNoNull(name: String) = getByName(name) ?: throw RuntimeException("No valid crop type '$name'") + + + fun getByItemName(itemName: String): CropType? { + if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") { + return MUSHROOM + } + return getByName(itemName) + } } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index 67b543c03..4218056e9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NEUItems import net.minecraft.client.Minecraft import net.minecraft.item.ItemStack import net.minecraft.network.play.client.C09PacketHeldItemChange @@ -121,13 +120,6 @@ class GardenAPI { cropsPerSecond[this] = speed } - fun itemNameToCropName(itemName: String): CropType? { - if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") { - return CropType.MUSHROOM - } - return CropType.getByName(itemName) - } - fun addGardenCropToList(crop: CropType, list: MutableList) { try { list.add(crop.icon) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index 917b40b85..41f8a0ba2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -274,7 +274,7 @@ class GardenVisitorFeatures { if (config.visitorExactAmountAndTime) { val multiplier = NEUItems.getMultiplier(internalName) val rawName = NEUItems.getItemStack(multiplier.first).name?.removeColor() ?: continue - CropType.getByName(rawName)?.let { + CropType.getByItemName(rawName)?.let { val speed = it.getSpeed() val cropAmount = multiplier.second.toLong() * amount val formatAmount = LorenzUtils.formatInteger(cropAmount) -- cgit