Skip to content

Commit

Permalink
Feature: Add Reminder to open Calendar for Temp Mayor (#2009)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
j10a1n15 and hannibal002 authored Jun 8, 2024
1 parent d5667f8 commit 7e1dc04
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ public class MiscConfig {
@FeatureToggle
public boolean replaceRomanNumerals = false;

@Expose
@ConfigOption(name = "Unknown Perkpocalypse Mayor Warning", desc = "Show a warning when the Unknown Perkpocalypse Mayor is unknown.")
@ConfigEditorBoolean
@FeatureToggle
public boolean unknownPerkpocalypseMayorWarning = true;

@ConfigOption(name = "Hide Far Entities", desc = "")
@Accordion
@Expose
Expand Down
34 changes: 31 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/data/MayorAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.features.fame.ReminderUtils
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.APIUtil
import at.hannibal2.skyhanni.utils.ChatUtils
Expand Down Expand Up @@ -44,33 +45,51 @@ import kotlin.time.Duration.Companion.minutes
object MayorAPI {

private val group = RepoPattern.group("mayorapi")

// TODO: Add Regex-test
val foxyExtraEventPattern by group.pattern(
"foxy.extraevent",
"Schedules an extra §.(?<event>.*) §.event during the year\\."
)

/**
* REGEX-TEST: The election room is now closed. Clerk Seraphine is doing a final count of the votes...
*/
private val electionOverPattern by group.pattern(
"election.over",
"§eThe election room is now closed\\. Clerk Seraphine is doing a final count of the votes\\.\\.\\."
)

/**
* REGEX-TEST: Calendar and Events
*/
private val calendarGuiPattern by group.pattern(
"calendar.gui",
"Calendar and Events"
)

/**
* REGEX-TEST: §dMayor Jerry
*/
private val jerryHeadPattern by group.pattern(
"jerry.head",
"§dMayor Jerry"
)
// TODO add regex tests

/**
* REGEX-TEST: §9Perkpocalypse Perks:
*/
private val perkpocalypsePerksPattern by group.pattern(
"perkpocalypse",
"§9Perkpocalypse Perks:"
)

var currentMayor: Mayor? = null
private set
private var lastMayor: Mayor? = null
var jerryExtraMayor: Pair<Mayor?, SimpleTimeMark> = null to SimpleTimeMark.farPast()
private set
private var lastMayor: Mayor? = null
var lastJerryExtraMayorReminder = SimpleTimeMark.farPast()

private var lastUpdate = SimpleTimeMark.farPast()
private var dispatcher = Dispatchers.IO
Expand Down Expand Up @@ -108,7 +127,16 @@ object MayorAPI {
if (jerryExtraMayor.first != null && jerryExtraMayor.second.isInPast() && Mayor.JERRY.isActive()) {
jerryExtraMayor = null to SimpleTimeMark.farPast()
ChatUtils.clickableChat(
"The Perkpocalypse Mayor has expired! Click here to update to the new temporary Mayor.",
"The Perkpocalypse Mayor has expired! Click here to update the new temporary Mayor.",
onClick = { HypixelCommands.calendar() }
)
}
if (Mayor.JERRY.isActive() && jerryExtraMayor.first == null && SkyHanniMod.feature.misc.unknownPerkpocalypseMayorWarning) {
if (lastJerryExtraMayorReminder.passedSince() < 5.minutes) return
if (ReminderUtils.isBusy()) return
lastJerryExtraMayorReminder = SimpleTimeMark.now()
ChatUtils.clickableChat(
"The Perkpocalypse Mayor is not known! Click here to update the temporary Mayor.",
onClick = { HypixelCommands.calendar() }
)
}
Expand Down

0 comments on commit 7e1dc04

Please sign in to comment.