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

Feature: reminder to open hoppity shop each year #1843

Merged
merged 8 commits into from
May 29, 2024
Merged
Changes from 1 commit
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
Next Next commit
reminder to open hoppity shop each year
appable0 committed May 20, 2024
commit 5e5d684213e99e0a10289e6b594b9799ed83a110
Original file line number Diff line number Diff line change
@@ -87,6 +87,12 @@ public class HoppityEggsConfig {
@FeatureToggle
public boolean highlightHoppityShop = true;

@Expose
@ConfigOption(name = "Hoppity Shop Reminder", desc = "Reminds you to open the Hoppity Shop each year.")
@ConfigEditorBoolean
@FeatureToggle
public boolean hoppityShopReminder = true;

@Expose
@ConfigOption(name = "Time in Chat", desc = "When the Egglocator can't find an egg, show the time until the next Hoppity event or egg spawn.")
@ConfigEditorBoolean
Original file line number Diff line number Diff line change
@@ -120,6 +120,9 @@ public static class PositionChange {

@Expose
public String targetName = null;

@Expose
public Integer hoppityShopYearOpened = -1;
}

@Expose
Original file line number Diff line number Diff line change
@@ -1,34 +1,59 @@
package at.hannibal2.skyhanni.features.event.hoppity

import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.InventoryUpdatedEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.features.fame.ReminderUtils
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SkyBlockTime
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds

object HoppityNpc {

private val config get() = HoppityEggsManager.config

private val lastReminderSent = SimpleTimeMark.farPast()
private var hoppityYearOpened
get() = ProfileStorageData.profileSpecific?.chocolateFactory?.hoppityShopYearOpened ?: -1
set(value) {
ProfileStorageData.profileSpecific?.chocolateFactory?.hoppityShopYearOpened = value
}

private var slotsToHighlight = mutableSetOf<Int>()
private var inShop = false

@SubscribeEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
if (!isEnabled()) return
if (event.inventoryName != "Hoppity") return
hoppityYearOpened = SkyBlockTime.now().year
inShop = true
}

private fun clear() {
inShop = false
slotsToHighlight.clear()
@SubscribeEvent
fun onSecondPassed(event: SecondPassedEvent) {
if (!isReminderEnabled()) return
if (ReminderUtils.isBusy()) return
if (hoppityYearOpened == SkyBlockTime.now().year) return
if (lastReminderSent.passedSince() > 30.seconds) return

ChatUtils.clickableChat(
"New rabbits are available at §aHoppity's Shop§e! §c(Click to disable these reminders)",
onClick = {
disableReminder()
},
oneTimeClick = true
)
}

@SubscribeEvent
@@ -54,6 +79,7 @@ object HoppityNpc {

@SubscribeEvent
fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
if (!isHighlightEnabled()) return
if (!inShop) return
for (slot in InventoryUtils.getItemsInOpenChest()) {
if (slot.slotIndex in slotsToHighlight) {
@@ -62,5 +88,15 @@ object HoppityNpc {
}
}

fun isEnabled() = LorenzUtils.inSkyBlock && config.highlightHoppityShop
private fun isHighlightEnabled() = LorenzUtils.inSkyBlock && config.highlightHoppityShop
private fun isReminderEnabled() = LorenzUtils.inSkyBlock && config.hoppityShopReminder

private fun clear() {
inShop = false
slotsToHighlight.clear()
}

private fun disableReminder() {
config.hoppityShopReminder = false
}
}