diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-15 22:48:15 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-15 22:48:15 +0100 |
commit | 17b3e2353e05db79b2e9087971e933d04120a814 (patch) | |
tree | e56fae0fb225446ad983b8f5a7e707c32c5ba129 /src/main/java/at/hannibal2/skyhanni/features | |
parent | 62d432def85f5fa763b5a093371e1bbc28d52edc (diff) | |
download | skyhanni-17b3e2353e05db79b2e9087971e933d04120a814.tar.gz skyhanni-17b3e2353e05db79b2e9087971e933d04120a814.tar.bz2 skyhanni-17b3e2353e05db79b2e9087971e933d04120a814.zip |
Added New Year Cake Reminder
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt new file mode 100644 index 000000000..d5c4e7739 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt @@ -0,0 +1,81 @@ +package at.hannibal2.skyhanni.features.event.winter + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.features.fame.ReminderUtils +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import io.github.moulberry.notenoughupdates.util.SkyBlockTime +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds + +class NewYearCakeReminder { + private val config get() = SkyHanniMod.feature.event.winter + private val sidebarDetectionPattern by RepoPattern.pattern( + "event.winter.newyearcake.reminder.sidebar", + "§dNew Year Event!§f (?<time>.*)" + ) + + private var cakeTime = false + private var lastReminderSend = SimpleTimeMark.farPast() + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (event.message == "§aYou claimed a §r§cNew Year Cake§r§a!") { + makedClaimed() + } + } + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + // cake already claimed + if (event.inventoryName == "Baker" && IslandType.HUB.isInIsland()) { + makedClaimed() + } + } + + private fun makedClaimed() { + val playerSpecific = ProfileStorageData.playerSpecific ?: return + playerSpecific.winter.cakeCollectedYear = SkyBlockTime.now().year + } + + private fun isClaimed(): Boolean { + val playerSpecific = ProfileStorageData.playerSpecific ?: return false + return playerSpecific.winter.cakeCollectedYear == SkyBlockTime.now().year + } + + @SubscribeEvent + fun onScoreboardChange(event: ScoreboardChangeEvent) { + cakeTime = event.newList.any { sidebarDetectionPattern.matches(it) } + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!LorenzUtils.inSkyBlock) return + if (event.repeatSeconds(1)) { + check() + } + } + + private fun check() { + if (!config.newYearCakeReminder) return + if (ReminderUtils.isBusy()) return + if (isClaimed()) return + + if (lastReminderSend.passedSince() < 30.seconds) return + lastReminderSend = SimpleTimeMark.now() + + LorenzUtils.clickableChat( + "Reminding you to grab the free New Year Cake in the Hub. Click here to warp to hub!", + "warp hub" + ) + } +} |