diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-02 15:08:26 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-02 15:08:26 +0100 |
commit | 80456b0dfbe08a1ab149752f65e8f5e73dcf2e61 (patch) | |
tree | ebdb8dfd290d8095842d1a9bd6bd5a1b1c1762df /src/main/java/at/hannibal2/skyhanni/features/garden | |
parent | 35d358151fdd3a344a28407a1da950d99f62675c (diff) | |
download | skyhanni-80456b0dfbe08a1ab149752f65e8f5e73dcf2e61.tar.gz skyhanni-80456b0dfbe08a1ab149752f65e8f5e73dcf2e61.tar.bz2 skyhanni-80456b0dfbe08a1ab149752f65e8f5e73dcf2e61.zip |
Amount and Time: Show the exact item amount and the remaining time when farmed manually. Especially useful for ironman.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt | 12 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt | 104 |
2 files changed, 78 insertions, 38 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt index a57beed0e..62fced2f5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -30,6 +30,10 @@ class GardenCropMilestoneDisplay { private val timeTillNextCrop: MutableMap<String, Long> get() = SkyHanniMod.feature.hidden.gardenTimeTillNextCropMilestone private val config: Garden get() = SkyHanniMod.feature.garden + companion object { + val cropsPerSecond: MutableMap<String, Int> get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond + } + @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (!isEnabled()) return @@ -45,6 +49,11 @@ class GardenCropMilestoneDisplay { if (GardenCropMilestones.cropCounter.values.sum() == 0L) { needsInventory = true } + if (cropsPerSecond.isEmpty()) { + for (key in GardenCropMilestones.cropCounter.keys) { + cropsPerSecond[key] = -1 + } + } } @SubscribeEvent @@ -237,12 +246,13 @@ class GardenCropMilestoneDisplay { progressDisplay.add(Collections.singletonList("§e$haveFormat§8/§e$needFormat")) if (averageSpeedPerSecond != 0) { + cropsPerSecond[it] = averageSpeedPerSecond val missing = need - have val missingTimeSeconds = missing / averageSpeedPerSecond val millis = missingTimeSeconds * 1000 timeTillNextCrop[it] = millis val duration = TimeUtils.formatDuration(millis) - progressDisplay.add(Collections.singletonList("§7In §b$duration")) + progressDisplay.add(Collections.singletonList("§7in §b$duration")) val format = LorenzUtils.formatInteger(averageSpeedPerSecond * 60) progressDisplay.add(Collections.singletonList("§7Crops/minute§8: §e$format")) 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 a43f9671f..3eb69a2ef 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -130,55 +130,85 @@ class GardenVisitorFeatures { fun onTooltip(event: ItemTooltipEvent) { if (!isEnabled()) return if (!nearby) return - if (!config.visitorShowPrice) return if (!inVisitorInventory) return val name = event.itemStack.name ?: return if (name != "§aAccept Offer") return - val list = event.toolTip - var totalPrice = 0.0 - var amountDifferentItems = 0 - var endReached = false - for ((i, l) in list.toMutableList().withIndex()) { - val line = l.substring(4) - if (line == "") { - if (amountDifferentItems > 1) { - val format = NumberUtil.format(totalPrice) - list[1] = list[1] + "$line §f(§6Total §6$format§f)" + // TODO remove + try { + val list = event.toolTip + var totalPrice = 0.0 + var amountItems = 0 + var endReached = false + for ((i, l) in list.toMutableList().withIndex()) { + val line = l.substring(4) + if (line == "") { + if (config.visitorShowPrice) { + if (amountItems > 1) { + val format = NumberUtil.format(totalPrice) + list[1] = list[1] + "$line §f(§6Total §6$format§f)" + } + } + endReached = true } - endReached = true - } - if (i > 1 && !endReached) { - val (itemName, amount) = ItemUtils.readItemAmount(line) - if (itemName != null) { - val internalName: String - try { - internalName = NEUItems.getInternalName(itemName) - } catch (e: NullPointerException) { - val message = "internal name is null: '$itemName'" - println(message) - LorenzUtils.error(message) - e.printStackTrace() - return + // Items Required + if (i > 1 && !endReached) { + val (itemName, amount) = ItemUtils.readItemAmount(line) + if (itemName != null) { + val internalName: String + try { + internalName = NEUItems.getInternalName(itemName) + } catch (e: NullPointerException) { + val message = "internal name is null: '$itemName'" + println(message) + LorenzUtils.error(message) + e.printStackTrace() + return + } + if (config.visitorShowPrice) { + val price = NEUItems.getPrice(internalName) * amount + totalPrice += price + val format = NumberUtil.format(price) + list[i] = "$line §7(§6$format§7)" + } + amountItems++ + + if (config.visitorExactAmountAndTime) { + val multiplier = NEUItems.getMultiplier(internalName) + val rawName = NEUItems.getItemStack(multiplier.first).name ?: continue + val crop = rawName.removeColor() + val cropAmount = multiplier.second.toLong() * amount + GardenCropMilestoneDisplay.cropsPerSecond[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!" + } + list.add(i + amountItems, " §7- $formatName($formatSpeed§7)") + } + } } - val price = NEUItems.getPrice(internalName) * amount - totalPrice += price - val format = NumberUtil.format(price) - list[i] = "$line §7(§6$format§7)" - amountDifferentItems++ } - } - if (config.visitorCopperPrice) { - val matcher = copperPattern.matcher(line) - if (matcher.matches()) { - val coppers = matcher.group(1).replace(",", "").toInt() - val pricePerCopper = NumberUtil.format((totalPrice / coppers).toInt()) - list[i] = list[i] + " §f(§7Copper price §6$pricePerCopper§f)" + if (config.visitorCopperPrice) { + val matcher = copperPattern.matcher(line) + if (matcher.matches()) { + val coppers = matcher.group(1).replace(",", "").toInt() + val pricePerCopper = NumberUtil.format((totalPrice / coppers).toInt()) + list[i] = list[i] + " §f(§7Copper price §6$pricePerCopper§f)" + } } } + + } catch (e: Exception) { + e.printStackTrace() + LorenzUtils.debug("crash!") } } |