Skip to content

Commit

Permalink
Fix: Griffin Pet warning Autopet (#2722)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
hannibal002 and hannibal002 authored Oct 13, 2024
1 parent 52e061e commit 0561f4b
Showing 1 changed file with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,66 @@
package at.hannibal2.skyhanni.features.event.diana

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.BurrowDugEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds

@SkyHanniModule
object GriffinPetWarning {

private val config get() = SkyHanniMod.feature.event.diana
private var wasCorrectPetAlready = false
private var lastWarnTime = SimpleTimeMark.farPast()

@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (!event.isMod(10)) return
if (!SkyHanniMod.feature.event.diana.petWarning) return
if (!config.petWarning) return
if (!DianaAPI.isDoingDiana()) return
if (!DianaAPI.hasSpadeInHand()) return

if (!DianaAPI.hasGriffinPet() && lastWarnTime.passedSince() > 30.seconds) {
val hasGriffinPet = DianaAPI.hasGriffinPet()
if (hasGriffinPet) {
wasCorrectPetAlready = true
return
}

if (wasCorrectPetAlready) return

warn()
}

@SubscribeEvent
fun onBurrowDug(event: BurrowDugEvent) {
DelayedRun.runDelayed(2.seconds) {
wasCorrectPetAlready = false
}
}

@SubscribeEvent
fun onIslandChange(event: IslandChangeEvent) {
DelayedRun.runDelayed(5.seconds) {
wasCorrectPetAlready = false
}
}

private fun warn() {
ChatUtils.clickToActionOrDisable(
"Reminder to use a Griffin pet for Mythological Ritual!",
config::petWarning,
actionName = "open pets menu",
action = { HypixelCommands.pet() },
)
if (lastWarnTime.passedSince() > 30.seconds) {
lastWarnTime = SimpleTimeMark.now()
LorenzUtils.sendTitle("§cGriffin Pet!", 3.seconds)
ChatUtils.chat("Reminder to use a Griffin pet for Mythological Ritual!")
}
}
}

0 comments on commit 0561f4b

Please sign in to comment.