From 86031f42f3f904e295c8e4a402777d747cf0dfe8 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 17 Sep 2023 09:21:11 +0200 Subject: migrate diana and bingo config into events --- .../event/anniversary/ActivePlayerTimer.kt | 76 ---------------------- .../event/anniversary/Year300RaffleEvent.kt | 75 +++++++++++++++++++++ .../features/event/diana/BurrowWarpHelper.kt | 6 +- .../features/event/diana/GriffinBurrowHelper.kt | 12 +++- .../event/diana/GriffinBurrowParticleFinder.kt | 7 +- .../features/event/diana/GriffinPetWarning.kt | 2 +- .../event/diana/InquisitorWaypointShare.kt | 2 +- .../features/event/diana/SoopyGuessBurrow.kt | 2 +- 8 files changed, 94 insertions(+), 88 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features/event') diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt deleted file mode 100644 index a83def532..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt +++ /dev/null @@ -1,76 +0,0 @@ -package at.hannibal2.skyhanni.features.event.anniversary - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NEUItems -import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems -import at.hannibal2.skyhanni.utils.SoundUtils -import at.hannibal2.skyhanni.utils.SoundUtils.playSound -import at.hannibal2.skyhanni.utils.TimeMark -import at.hannibal2.skyhanni.utils.TimeUtils.format -import at.hannibal2.skyhanni.utils.renderables.Renderable -import io.github.moulberry.notenoughupdates.util.SkyBlockTime -import net.minecraft.init.Items -import net.minecraft.item.ItemStack -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.time.Instant -import kotlin.time.Duration.Companion.minutes -import kotlin.time.Duration.Companion.seconds - -object ActivePlayerTimer { - val displayItem by lazy { NEUItems.getItemStackOrNull("EPOCH_CAKE_ORANGE") ?: ItemStack(Items.clock) } - - private var lastTimerReceived = TimeMark.never() - private var lastTimeAlerted = TimeMark.never() - - private var overlay: List? = null - - @SubscribeEvent - fun onChat(event: LorenzChatEvent) { - if (event.message == "§6§lACTIVE PLAYER! §eYou gained §b+1 Raffle Ticket§e!") { - lastTimerReceived = TimeMark.now() - } - } - - fun isEnabled(): Boolean { - return SkyHanniMod.feature.misc.century.enableActiveTimer && - Instant.now().isBefore(SkyBlockTime(301).toInstant()) && - LorenzUtils.inSkyBlock - } - - - @SubscribeEvent - fun onRender(event: GuiRenderEvent.GameOverlayRenderEvent) { - SkyHanniMod.feature.misc.century.activeTimerPosition.renderSingleLineWithItems( - overlay ?: return, - posLabel = "300þ Anniversary Active Timer" - ) - } - - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!isEnabled()) { - overlay = null - return - } - val p = lastTimerReceived.passedTime() - val timeLeft = if (p > 20.minutes) { - 0.seconds - } else { - 20.minutes - p - } - if (p.isFinite() && timeLeft < 1.seconds && lastTimeAlerted.passedTime() > 5.minutes && SkyHanniMod.feature.misc.century.enableActiveAlert) { - SoundUtils.centuryActiveTimerAlert.playSound() - lastTimeAlerted = TimeMark.now() - } - overlay = listOf( - Renderable.itemStack(displayItem), - Renderable.string("§eTime Left: ${timeLeft.format()}") - ) - } - - -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt new file mode 100644 index 000000000..948d04269 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt @@ -0,0 +1,75 @@ +package at.hannibal2.skyhanni.features.event.anniversary + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems +import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.SoundUtils.playSound +import at.hannibal2.skyhanni.utils.TimeMark +import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.renderables.Renderable +import io.github.moulberry.notenoughupdates.util.SkyBlockTime +import net.minecraft.init.Items +import net.minecraft.item.ItemStack +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.time.Instant +import kotlin.time.Duration.Companion.minutes +import kotlin.time.Duration.Companion.seconds + +object Year300RaffleEvent { + private val config get() = SkyHanniMod.feature.event.century + val displayItem by lazy { NEUItems.getItemStackOrNull("EPOCH_CAKE_ORANGE") ?: ItemStack(Items.clock) } + + private var lastTimerReceived = TimeMark.never() + private var lastTimeAlerted = TimeMark.never() + + private var overlay: List? = null + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (event.message == "§6§lACTIVE PLAYER! §eYou gained §b+1 Raffle Ticket§e!") { + lastTimerReceived = TimeMark.now() + } + } + + fun isEnabled() = config.enableActiveTimer && + Instant.now().isBefore(SkyBlockTime(301).toInstant()) && + LorenzUtils.inSkyBlock + + + @SubscribeEvent + fun onRender(event: GuiRenderEvent.GameOverlayRenderEvent) { + config.activeTimerPosition.renderSingleLineWithItems( + overlay ?: return, + posLabel = "300þ Anniversary Active Timer" + ) + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) { + overlay = null + return + } + val p = lastTimerReceived.passedTime() + val timeLeft = if (p > 20.minutes) { + 0.seconds + } else { + 20.minutes - p + } + if (p.isFinite() && timeLeft < 1.seconds && lastTimeAlerted.passedTime() > 5.minutes && config.enableActiveAlert) { + SoundUtils.centuryActiveTimerAlert.playSound() + lastTimeAlerted = TimeMark.now() + } + overlay = listOf( + Renderable.itemStack(displayItem), + Renderable.string("§eTime Left: ${timeLeft.format()}") + ) + } + + +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt index fe9efd09a..f96c6d260 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt @@ -12,7 +12,6 @@ import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent import org.lwjgl.input.Keyboard class BurrowWarpHelper { - private val config get() = SkyHanniMod.feature.diana private var lastWarpTime = 0L private var lastWarp: WarpPoint? = null @@ -58,6 +57,7 @@ class BurrowWarpHelper { } companion object { + private val config get() = SkyHanniMod.feature.event.diana var currentWarp: WarpPoint? = null fun shouldUseWarps(target: LorenzVec) { @@ -93,10 +93,10 @@ class BurrowWarpHelper { ) { HUB("Hub", LorenzVec(-3, 70, -70), 2), CASTLE("Castle", LorenzVec(-250, 130, 45), 10), - CRYPT("Crypt", LorenzVec(-190, 74, -88), 15, { SkyHanniMod.feature.diana.ignoredWarps.crypt }), + CRYPT("Crypt", LorenzVec(-190, 74, -88), 15, { config.ignoredWarps.crypt }), DA("Dark Auction", LorenzVec(91, 74, 173), 2), MUSEUM("Museum", LorenzVec(-75, 76, 81), 2), - WIZARD("Wizard", LorenzVec(42.5, 122.0, 69.0), 5, { SkyHanniMod.feature.diana.ignoredWarps.wizard }), + WIZARD("Wizard", LorenzVec(42.5, 122.0, 69.0), 5, { config.ignoredWarps.wizard }), ; fun distance(other: LorenzVec): Double = other.distance(location) + extraBlocks diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt index d3c6038f2..1a6750d85 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.EntityMovementData import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.* @@ -18,7 +19,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds object GriffinBurrowHelper { - private val config get() = SkyHanniMod.feature.diana + private val config get() = SkyHanniMod.feature.event.diana private var guessLocation: LorenzVec? = null private var targetLocation: LorenzVec? = null @@ -137,7 +138,7 @@ object GriffinBurrowHelper { sendTip(event) val playerLocation = LocationUtils.playerLocation() - if (SkyHanniMod.feature.diana.inquisitorSharing.enabled) { + if (config.inquisitorSharing.enabled) { for (inquis in InquisitorWaypointShare.waypoints.values) { val playerName = inquis.fromPlayer val location = inquis.location @@ -163,7 +164,7 @@ object GriffinBurrowHelper { } if (InquisitorWaypointShare.waypoints.isNotEmpty()) { - if (SkyHanniMod.feature.diana.inquisitorSharing.focusInquisitor) { + if (config.inquisitorSharing.focusInquisitor) { return } } @@ -192,6 +193,11 @@ object GriffinBurrowHelper { } } + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(2, "diana", "event.diana") + } + private fun sendTip(event: RenderWorldLastEvent) { teleportedLocation?.let { teleportedLocation = null diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt index 31571b30b..b16df2c70 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt @@ -15,6 +15,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class GriffinBurrowParticleFinder { + private val config get() = SkyHanniMod.feature.event.diana private val recentlyDugParticleBurrows = mutableListOf() private val burrows = mutableMapOf() @@ -78,7 +79,7 @@ class GriffinBurrowParticleFinder { @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) fun onChatPacket(event: PacketEvent.ReceiveEvent) { if (!LorenzUtils.inSkyBlock) return - if (!SkyHanniMod.feature.diana.burrowsSoopyGuess) return + if (!config.burrowsSoopyGuess) return if (LorenzUtils.skyBlockIsland != IslandType.HUB) return val packet = event.packet @@ -149,7 +150,7 @@ class GriffinBurrowParticleFinder { @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { - if (!SkyHanniMod.feature.diana.burrowsSoopyGuess) return + if (!config.burrowsSoopyGuess) return if (LorenzUtils.skyBlockIsland != IslandType.HUB) return val message = event.message if (message.startsWith("§eYou dug out a Griffin Burrow!") || @@ -171,7 +172,7 @@ class GriffinBurrowParticleFinder { @SubscribeEvent fun onBlockClick(event: BlockClickEvent) { if (!LorenzUtils.inSkyBlock) return - if (!SkyHanniMod.feature.diana.burrowsSoopyGuess) return + if (!config.burrowsSoopyGuess) return if (LorenzUtils.skyBlockIsland != IslandType.HUB) return val pos = event.position diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinPetWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinPetWarning.kt index 5a578590f..679c493ca 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinPetWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinPetWarning.kt @@ -17,7 +17,7 @@ class GriffinPetWarning { fun onTick(event: LorenzTickEvent) { if (!event.isMod(20)) return if (!IslandType.HUB.isInIsland()) return - if (!SkyHanniMod.feature.diana.petWarning) return + if (!SkyHanniMod.feature.event.diana.petWarning) return if (!DianaAPI.isRitualActive()) return if (!DianaAPI.hasSpadeInHand()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index 7a8ea5d2b..14f4305ab 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -20,7 +20,7 @@ import org.lwjgl.input.Keyboard import kotlin.time.Duration.Companion.seconds object InquisitorWaypointShare { - private val config get() = SkyHanniMod.feature.diana.inquisitorSharing + private val config get() = SkyHanniMod.feature.event.diana.inquisitorSharing private val partyPattern = "§9Party §8> (?.*)§f: §rx: (?-?[0-9]{1,4}), y: (?-?[0-9]{1,4}), z: (?-?[0-9]{1,4})\\b".toPattern() private val diedPattern = "§9Party §8> (?.*)§f: §rInquisitor dead!".toPattern() diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/SoopyGuessBurrow.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/SoopyGuessBurrow.kt index 079d6cecf..0ca67ad8e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/SoopyGuessBurrow.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/SoopyGuessBurrow.kt @@ -276,6 +276,6 @@ class SoopyGuessBurrow { } private fun isEnabled(): Boolean { - return LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.HUB && SkyHanniMod.feature.diana.burrowsSoopyGuess + return LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.HUB && SkyHanniMod.feature.event.diana.burrowsSoopyGuess } } \ No newline at end of file -- cgit