diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-15 22:11:12 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-15 22:11:12 +0100 |
commit | 78c845337fb145ecbe90d7b6814ea9c03ea3134d (patch) | |
tree | b12ffc6e538d97bec99c4c9a9168f66b6d098754 /src/main/java | |
parent | 09e6eaecfb6c924e0bd1f13d66f7faf2f190e2c8 (diff) | |
download | skyhanni-78c845337fb145ecbe90d7b6814ea9c03ea3134d.tar.gz skyhanni-78c845337fb145ecbe90d7b6814ea9c03ea3134d.tar.bz2 skyhanni-78c845337fb145ecbe90d7b6814ea9c03ea3134d.zip |
Fixed Hay Bale costs in garden visitor price calculation
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt | 12 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt | 32 |
2 files changed, 26 insertions, 18 deletions
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 44c80f381..e5c6b72ca 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -112,11 +112,15 @@ class GardenAPI { return -1 } - fun getCropsPerSecond(itemName: String): Int? { - if (itemName.endsWith(" Mushroom")) { - return cropsPerSecond["Mushroom"] + fun getCropsPerSecond(itemName: String): Int { + return cropsPerSecond[itemNameToCropName(itemName)]!! + } + + fun itemNameToCropName(itemName: String): String { + if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") { + return "Mushroom" } - return cropsPerSecond[itemName] + return itemName } } }
\ No newline at end of file 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 a7bee0a59..d80cdc382 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -155,9 +155,14 @@ class GardenVisitorFeatures { if (i > 1 && !endReached) { val (itemName, amount) = ItemUtils.readItemAmount(line) if (itemName != null) { - val internalName: String + var internalName: String try { internalName = NEUItems.getInternalName(itemName) + // This fixes a NEU bug with §9Hay Bale (cosmetic item) + // TODO remove workaround when this is fixed in neu + if (internalName == "HAY_BALE") { + internalName = "HAY_BLOCK" + } } catch (e: NullPointerException) { val message = "internal name is null: '$itemName'" println(message) @@ -169,7 +174,7 @@ class GardenVisitorFeatures { totalPrice += price if (config.visitorShowPrice) { val format = NumberUtil.format(price) - list[i+ itemsWithSpeedCounter] = "$line §7(§6$format§7)" + list[i + itemsWithSpeedCounter] = "$line §7(§6$format§7)" } itemsCounter++ @@ -178,19 +183,18 @@ class GardenVisitorFeatures { val rawName = NEUItems.getItemStack(multiplier.first).name ?: continue val crop = rawName.removeColor() val cropAmount = multiplier.second.toLong() * amount - GardenAPI.getCropsPerSecond(crop)?.let { - val formatAmount = LorenzUtils.formatInteger(cropAmount) - val formatName = "§e${formatAmount}§7x $crop " - val formatSpeed = if (it != -1) { - val missingTimeSeconds = cropAmount / it - val duration = TimeUtils.formatDuration(missingTimeSeconds * 1000) - "in §b$duration" - } else { - "§cno speed data!" - } - itemsWithSpeedCounter++ - list.add(i + itemsWithSpeedCounter, " §7- $formatName($formatSpeed§7)") + val speed = GardenAPI.getCropsPerSecond(crop) + val formatAmount = LorenzUtils.formatInteger(cropAmount) + val formatName = "§e${formatAmount}§7x $crop " + val formatSpeed = if (speed != -1) { + val missingTimeSeconds = cropAmount / speed + val duration = TimeUtils.formatDuration(missingTimeSeconds * 1000) + "in §b$duration" + } else { + "§cno speed data!" } + itemsWithSpeedCounter++ + list.add(i + itemsWithSpeedCounter, " §7- $formatName($formatSpeed§7)") } } } |