diff options
author | David Cole <40234707+DavidArthurCole@users.noreply.github.com> | 2024-05-29 02:16:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-29 08:16:49 +0200 |
commit | 85fd32ffd2eb2501c65af3a1c093eea5a23483e0 (patch) | |
tree | 6316cb462f9c57a5a132f1d5c829ad8613a8f53c /src/main | |
parent | 64f83ca3f4c70b6008ad269b958fae5515d3c67c (diff) | |
download | skyhanni-85fd32ffd2eb2501c65af3a1c093eea5a23483e0.tar.gz skyhanni-85fd32ffd2eb2501c65af3a1c093eea5a23483e0.tar.bz2 skyhanni-85fd32ffd2eb2501c65af3a1c093eea5a23483e0.zip |
Improvement: Combine duplicate time comparison into compacted chat message (#1887)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com>
Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main')
2 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt index b66f06891..fdb029fa6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt @@ -2,11 +2,13 @@ package at.hannibal2.skyhanni.features.event.hoppity import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager.getEggType +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.fromNow +import at.hannibal2.skyhanni.utils.TimeUtils.format import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds @@ -20,6 +22,7 @@ object HoppityEggsCompactChat { private var newRabbit = false private var lastChatMeal: HoppityEggType? = null private var lastDuplicateAmount: Long? = null + private val config get() = ChocolateFactoryAPI.config fun compactChat(event: LorenzChatEvent, lastDuplicateAmount: Long? = null) { lastDuplicateAmount?.let { @@ -57,7 +60,12 @@ object HoppityEggsCompactChat { return if (duplicate) { val format = lastDuplicateAmount?.let { NumberUtil.format(it) } ?: "?" - "$mealName Egg! §7Duplicate $lastName §7(§6+$format Chocolate§7)" + val timeFormatted = lastDuplicateAmount?.let { + ChocolateFactoryAPI.timeUntilNeed(it).format(maxUnits = 2) + } ?: "?" + + val timeStr = if (config.showDuplicateTime) ", §a+§b$timeFormatted§7" else "" + "$mealName Egg! §7Duplicate $lastName §7(§6+$format Chocolate§7$timeStr)" } else if (newRabbit) { "$mealName Egg! §d§lNEW $lastName §7(${lastProfit}§7)" } else "?" diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt index 356794b7e..a8134cedf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt @@ -18,6 +18,7 @@ import kotlin.time.Duration.Companion.seconds object ChocolateFactoryBarnManager { private val config get() = ChocolateFactoryAPI.config + private val hoppityConfig get() = HoppityEggsManager.config private val profileStorage get() = ChocolateFactoryAPI.profileStorage private val newRabbitPattern by ChocolateFactoryAPI.patternGroup.pattern( @@ -54,7 +55,7 @@ object ChocolateFactoryBarnManager { rabbitDuplicatePattern.matchMatcher(event.message) { HoppityEggsManager.shareWaypointPrompt() val amount = group("amount").formatLong() - if (config.showDuplicateTime) { + if (config.showDuplicateTime && !hoppityConfig.compactChat) { val format = ChocolateFactoryAPI.timeUntilNeed(amount).format(maxUnits = 2) DelayedRun.runNextTick { ChatUtils.chat("§7(§a+§b$format §aof production§7)") |