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: Broodmother countdown when imminent #2602

Merged
merged 4 commits into from
Sep 28, 2024
Merged
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 @@ -50,7 +50,7 @@ object BroodmotherFeatures {
fun onTabListUpdate(event: WidgetUpdateEvent) {
if (!event.isWidget(TabWidget.BROODMOTHER)) return
val newStage = event.widget.matchMatcherFirstLine { group("stage") } ?: ""
if (newStage.isNotEmpty()) {
if (newStage.isNotEmpty() && newStage != lastStage.toString()) {
lastStage = currentStage
currentStage = StageEntry.valueOf(newStage.replace("!", "").uppercase())
onStageUpdate()
Expand All @@ -60,7 +60,7 @@ object BroodmotherFeatures {
private fun onStageUpdate() {
ChatUtils.debug("New Broodmother stage: $currentStage")

if (lastStage == null && onServerJoin()) return
if (onServerJoin()) return

// ignore Hypixel bug where the stage may temporarily revert to Imminent after the Broodmother's death
if (currentStage == StageEntry.IMMINENT && lastStage == StageEntry.ALIVE) return
Expand All @@ -70,15 +70,15 @@ object BroodmotherFeatures {
return
}

val lastStage = lastStage ?: return
val timeUntilSpawn = currentStage?.minutes?.minutes ?: return
broodmotherSpawnTime = SimpleTimeMark.now() + timeUntilSpawn

if (currentStage == StageEntry.IMMINENT && config.imminentWarning) {
playImminentWarning()
return
}

val lastStage = lastStage ?: return
val timeUntilSpawn = currentStage?.minutes?.minutes ?: return
broodmotherSpawnTime = SimpleTimeMark.now() + timeUntilSpawn

if (currentStage !in config.stages) return
if (currentStage == StageEntry.SLAIN) {
onBroodmotherSlain()
Expand All @@ -91,19 +91,19 @@ object BroodmotherFeatures {
}

private fun onServerJoin(): Boolean {
if (lastStage != null || !config.stageOnJoin) return false
// don't send if user has config enabled for either of the alive messages
// this is so that two messages aren't immediately sent upon joining a server
if (config.stageOnJoin && !(currentStage == StageEntry.ALIVE && isAliveMessageEnabled())) {
if (!(currentStage == StageEntry.ALIVE && isAliveMessageEnabled())) {
val pluralize = StringUtils.pluralize(currentStage?.minutes ?: 0, "minute")
var message = "The Broodmother's current stage in this server is ${currentStage.toString().replace("!", "")}§e."
if (currentStage?.minutes != 0) {
message += " It will spawn §bwithin ${currentStage?.minutes} $pluralize§e."
}
ChatUtils.chat(message)
return true
} else {
return false
}
return false
}

private fun onBroodmotherSpawn() {
Expand Down Expand Up @@ -150,6 +150,9 @@ object BroodmotherFeatures {
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
if (!isCountdownEnabled()) return
if (display.isEmpty()) return
if (broodmotherSpawnTime.isInPast() && !broodmotherSpawnTime.isFarPast()) {
display = "§4Broodmother spawning now!"
}

config.countdownPosition.renderString(display, posLabel = "Broodmother Countdown")
}
Expand All @@ -159,7 +162,7 @@ object BroodmotherFeatures {
if (!isCountdownEnabled()) return

if (broodmotherSpawnTime.isFarPast()) {
if (lastStage != null && currentStage == StageEntry.ALIVE) {
if (currentStage == StageEntry.ALIVE) {
display = "§4Broodmother spawned!"
}
} else {
Expand Down
Loading