diff options
Diffstat (limited to 'src/main/java')
4 files changed, 92 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 64b3020b4..fad364296 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -118,6 +118,7 @@ import at.hannibal2.skyhanni.features.event.lobby.waypoints.christmas.PresentWay import at.hannibal2.skyhanni.features.event.lobby.waypoints.halloween.BasketWaypoints import at.hannibal2.skyhanni.features.event.spook.TheGreatSpook import at.hannibal2.skyhanni.features.event.winter.JyrreTimer +import at.hannibal2.skyhanni.features.event.winter.NewYearCakeReminder import at.hannibal2.skyhanni.features.event.winter.UniqueGiftCounter import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder import at.hannibal2.skyhanni.features.fame.CityProjectFeatures @@ -676,6 +677,7 @@ class SkyHanniMod { loadModule(HighlightPlaceableNpcs()) loadModule(PresentWaypoints()) loadModule(JyrreTimer()) + loadModule(NewYearCakeReminder()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index a01c8d7e5..4a9c94fb5 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -92,6 +92,9 @@ public class Storage { @Expose public int amountGifted = 0; + + @Expose + public int cakeCollectedYear = 0; } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java index ae95b62f3..458813f42 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java @@ -38,4 +38,10 @@ public class WinterConfig { @Expose public Position islandCloseTimePosition = new Position(10, 10, false, true); + @Expose + @ConfigOption(name = "New Year Cake Reminder", desc = "Reminds while the new year cake can be collected in the hub.") + @ConfigEditorBoolean + @FeatureToggle + public boolean newYearCakeReminder = true; + } 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" + ) + } +} |