From 1dca79a8fd0428f7bd5491d1b6e7537e7ad01f31 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sun, 13 Oct 2024 12:03:25 -0400 Subject: [PATCH] Formatting --- .../skyhanni/features/chat/StashCompact.kt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt index 8617dc193215..29a2689287bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NumberUtil.formatIntOrNull import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches @@ -16,7 +17,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object StashCompact { - // + // private val patternGroup = RepoPattern.group("stash.compact") /** @@ -56,7 +57,7 @@ object StashCompact { "generic", "§eOne or more (?:item|material)s? didn't fit in your inventory and were added to your (?:item|material) stash! §6Click here §eto pick them up!", ) - // + // private val config get() = SkyHanniMod.feature.chat.filterType.stashMessages @@ -76,14 +77,14 @@ object StashCompact { } materialCountPattern.matchMatcher(event.message) { - groupOrNull("count")?.replace(",", "")?.toIntOrNull()?.let { count -> + groupOrNull("count")?.formatIntOrNull()?.let { count -> lastMaterialCount = count } event.blockedReason = "stash_compact" } differingMaterialsCountPattern.matchMatcher(event.message) { - groupOrNull("count")?.replace(",", "")?.toIntOrNull()?.let { count -> + groupOrNull("count")?.formatIntOrNull()?.let { count -> lastDifferingMaterialsCount = count } groupOrNull("type")?.let { type -> @@ -102,16 +103,16 @@ object StashCompact { } private fun sendCompactedStashMessage() { - val name = StringUtils.pluralize(lastMaterialCount, lastType) - val total = StringUtils.pluralize(lastDifferingMaterialsCount, "type") + val typeNameFormat = StringUtils.pluralize(lastMaterialCount, lastType) + val typeFormat = StringUtils.pluralize(lastDifferingMaterialsCount, "type") ChatUtils.clickableChat( - "§7You have §3${lastMaterialCount} §7$name in stash, §8totalling $lastDifferingMaterialsCount $total§7. " + - "§3Click to ${if (config.useViewStash) "view" else "pickup"} stash§7.", + "§eYou have §6${lastMaterialCount} §e$typeNameFormat in stash§6, " + + "§etotalling §6$lastDifferingMaterialsCount $typeFormat§6. " + + "§eClick to ${if (config.useViewStash) "§6view" else "§6pickup"} §estash§6.", onClick = { if (config.useViewStash) HypixelCommands.viewStash(lastType) else HypixelCommands.pickupStash() }, - prefix = false, ) lastSentMaterialCount = lastMaterialCount lastSentType = lastType