Skip to content

Commit

Permalink
Fix: Compact Stash - Item Stash & Empty Line (#2781)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
DavidArthurCole and hannibal002 authored Oct 20, 2024
1 parent a4a6be6 commit 564c5da
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import at.hannibal2.skyhanni.config.FeatureToggle;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;

Expand All @@ -14,6 +15,14 @@ public class StashConfig {
@FeatureToggle
public boolean enabled = true;

@ConfigOption(
name = "§cNotice",
desc = "Hypixel sends un-detectable empty messages wrapping the stash message. " +
"Enable §e§l/sh empty messages §r§7to hide them."
)
@ConfigEditorInfoText
public String notice = "";

@Expose
@ConfigOption(name = "Hide Duplicate Warnings", desc = "Hide duplicate warnings for previously reported stash counts.")
@ConfigEditorBoolean
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/at/hannibal2/skyhanni/features/chat/StashCompact.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ object StashCompact {
/**
* REGEX-TEST: §f §7You have §3226 §7materials stashed away!
* REGEX-TEST: §f §7You have §31,000 §7items stashed away!
* REGEX-TEST: §f §7You have §a2 §7items stashed away!
*/
private val materialCountPattern by patternGroup.pattern(
"material.count",
"§f *§7You have §3(?<count>[\\d,]+) (?:§.)+(?<type>item|material)s? stashed away!.*",
"§f *§7You have §.(?<count>[\\d,]+) (?:§.)+(?<type>item|material)s? stashed away!.*",
)

/**
Expand All @@ -42,10 +43,11 @@ object StashCompact {

/**
* REGEX-TEST: §f §3§l>>> §3§lCLICK HERE§b to pick them up! §3§l<<<
* REGEX-TEST: §f §6§l>>> §6§lCLICK HERE§e to pick them up! §6§l<<<
*/
private val pickupStashPattern by patternGroup.pattern(
"pickup.stash",
"§f *§3§l>>> §3§lCLICK HERE§b to pick (?:them|it) up! §3§l<<<.*",
"§f *§.§l>>> §.§lCLICK HERE§. to pick (?:them|it) up! §.§l<<<.*",
)

/**
Expand Down Expand Up @@ -104,10 +106,12 @@ object StashCompact {

private fun sendCompactedStashMessage() {
val typeNameFormat = StringUtils.pluralize(lastMaterialCount, lastType)
val typeFormat = StringUtils.pluralize(lastDifferingMaterialsCount, "type")
val typeStringExtra = lastDifferingMaterialsCount.let {
if (it == 0) "." else ", §etotalling §6$it ${StringUtils.pluralize(it, "type")}§6."
}

ChatUtils.clickableChat(
"§eYou have §6$lastMaterialCount §e$typeNameFormat in stash§6, " +
"§etotalling §6$lastDifferingMaterialsCount $typeFormat§6. " +
"§eYou have §6$lastMaterialCount §e$typeNameFormat in stash§6${typeStringExtra} " +
"§eClick to ${if (config.useViewStash) "§6view" else "§6pickup"} §estash§6.",
onClick = {
if (config.useViewStash) HypixelCommands.viewStash(lastType)
Expand All @@ -116,6 +120,9 @@ object StashCompact {
)
lastSentMaterialCount = lastMaterialCount
lastSentType = lastType
// Dirty, but item stash doesn't always have differing materials count,
// and we don't compare this value to the last one, so we can reset it here
lastDifferingMaterialsCount = 0
}

private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
Expand Down

0 comments on commit 564c5da

Please sign in to comment.