Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Compact Stash - Item Stash & Empty Line #2781

Merged
merged 8 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading