From 8c5e53facf75158bd8b0f4875f71133bf6a365e3 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 11 Jan 2024 12:42:13 +0100 Subject: creating function addTotalProfit for item trackers and fixed wrong calculation when zero bosses killed in slayer profit trackers --- .../skyhanni/utils/tracker/SkyHanniItemTracker.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/main/java/at/hannibal2/skyhanni/utils') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt index 8dab120fa..b831ade3f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt @@ -172,4 +172,18 @@ class SkyHanniItemTracker( } } + fun addTotalProfit(profit: Double, totalAmount: Long, action: String): Renderable { + val profitFormat = profit.addSeparators() + val profitPrefix = if (profit < 0) "§c" else "§6" + + val tips = if (totalAmount > 0) { + val profitPerCatch = profit / totalAmount + val profitPerCatchFormat = NumberUtil.format(profitPerCatch) + listOf("§7Profit per $action: $profitPrefix$profitPerCatchFormat") + } else emptyList() + + val text = "§eTotal Profit: $profitPrefix$profitFormat coins" + return Renderable.hoverTips(text, tips) + } + } -- cgit