diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-16 02:06:14 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-16 02:06:14 +0100 |
commit | 7a6ce2c5d4ffce1cb8cc5c4c27ae5c938236645e (patch) | |
tree | 8567f5b39bfd612d63bd85acee2ead5560fd6e53 /src/main/java/at/hannibal2/skyhanni | |
parent | 0be549c5a42ff04cfab5d961891671e97eaa52d8 (diff) | |
download | skyhanni-7a6ce2c5d4ffce1cb8cc5c4c27ae5c938236645e.tar.gz skyhanni-7a6ce2c5d4ffce1cb8cc5c4c27ae5c938236645e.tar.bz2 skyhanni-7a6ce2c5d4ffce1cb8cc5c4c27ae5c938236645e.zip |
Code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
3 files changed, 15 insertions, 20 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 4553d901c..bc440cf6a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt @@ -99,7 +99,7 @@ class CropMoneyDisplay { for ((internalName, amount) in multipliers) { val price = NEUItems.getPrice(internalName) val cropName = cropNames[internalName]!! - val speed = GardenAPI.getCropsPerSecond(cropName) + val speed = GardenAPI.getCropsPerSecond(cropName)!! // No speed data for item in hand if (speed == -1) continue 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 71ebe5ea9..37d2e1f18 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -112,14 +112,8 @@ class GardenAPI { return -1 } - fun getCropsPerSecond(itemName: String): Int { - val name = itemNameToCropName(itemName) - val result = cropsPerSecond[name] - if (result == null) { - println("getCropsPerSecond is null for '$name'") - return -1 - } - return result + fun getCropsPerSecond(itemName: String): Int? { + return cropsPerSecond[itemNameToCropName(itemName)] } fun itemNameToCropName(itemName: String): String { 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 d80cdc382..6843fefdd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -183,18 +183,19 @@ class GardenVisitorFeatures { val rawName = NEUItems.getItemStack(multiplier.first).name ?: continue val crop = rawName.removeColor() val cropAmount = multiplier.second.toLong() * amount - 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!" + 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)") } - itemsWithSpeedCounter++ - list.add(i + itemsWithSpeedCounter, " §7- $formatName($formatSpeed§7)") } } } |