diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-17 00:49:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-17 00:49:06 +0200 |
commit | fa47b1831317286be018c32f30af8f57cbc8bcd9 (patch) | |
tree | 06c4efc0444e24efa377c96522b3645f1a52efb2 /src/main | |
parent | 5aa31512519c1b0d8a5db49b5a35273ac42bd4df (diff) | |
download | skyhanni-fa47b1831317286be018c32f30af8f57cbc8bcd9.tar.gz skyhanni-fa47b1831317286be018c32f30af8f57cbc8bcd9.tar.bz2 skyhanni-fa47b1831317286be018c32f30af8f57cbc8bcd9.zip |
Improvement: Fix Diana chat help (#1808)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main')
3 files changed, 130 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaFixChat.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaFixChat.kt new file mode 100644 index 000000000..04de77ce9 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaFixChat.kt @@ -0,0 +1,121 @@ +package at.hannibal2.skyhanni.features.event.diana + +import at.hannibal2.skyhanni.data.ClickType +import at.hannibal2.skyhanni.events.BurrowGuessEvent +import at.hannibal2.skyhanni.events.ItemClickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.features.event.diana.DianaAPI.isDianaSpade +import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.HypixelCommands +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.minutes +import kotlin.time.Duration.Companion.seconds + +class DianaFixChat { + + private var hasSetParticleQuality = false + private var hasSetToggleMusic = false + private var lastParticleQualityPrompt = SimpleTimeMark.farPast() + private var lastToggleMusicPrompt = SimpleTimeMark.farPast() + private var errorCounter = 0 + + private var lastSpadeUse = SimpleTimeMark.farPast() + private var lastErrorTime = SimpleTimeMark.farPast() + private var foundGuess = false + + @SubscribeEvent + fun onSecondPassed(event: SecondPassedEvent) { + if (!isEnabled()) return + if (lastSpadeUse.passedSince() > 1.minutes) return + + if (foundGuess) { + lastErrorTime = SimpleTimeMark.farPast() + return + } + // particles dont work if a valid target point is close + if (GriffinBurrowHelper.targetLocation != null) return + val spadeUse = lastSpadeUse.passedSince() + if (spadeUse <= 3.seconds) return + + if (lastErrorTime == lastSpadeUse) return + lastErrorTime = lastSpadeUse + + noGuessFound() + } + + private fun noGuessFound() { + errorCounter++ + if (errorCounter == 1) { + ChatUtils.chat("Could not find Diana Guess using sound and particles, please try again. (Was this a funny sound easter egg?)") + return + } + + println("error") + if (!hasSetParticleQuality) { + if (lastParticleQualityPrompt.passedSince() > 30.seconds) { + lastParticleQualityPrompt = SimpleTimeMark.now() + ChatUtils.clickableChat( + "§cError detecting Diana Guess! §eClick here to set the particle quality to high!", + onClick = { + hasSetParticleQuality = true + HypixelCommands.particleQuality("high") + errorCounter = 0 + ChatUtils.chat("Now try again!") + }) + } + } else { + if (!hasSetToggleMusic) { + if (lastToggleMusicPrompt.passedSince() > 30.seconds) { + lastToggleMusicPrompt = SimpleTimeMark.now() + ChatUtils.clickableChat( + "§cError detecting Diana Guess! Changing the Particle Quality has not worked :( " + + "§eClick here to disable hypixel music!", + onClick = { + hasSetToggleMusic = true + HypixelCommands.toggleMusic() + errorCounter = 0 + ChatUtils.chat("Now try again, please!") + }) + } + } else { + ErrorManager.logErrorStateWithData( + "Could not find diana guess point", + "diana guess point failed to load after /pq and /togglemusic", + "errorCounter" to errorCounter + ) + } + } + } + + @SubscribeEvent + fun onItemClick(event: ItemClickEvent) { + if (!isEnabled()) return + if (event.clickType != ClickType.RIGHT_CLICK) return + val item = event.itemInHand ?: return + if (!item.isDianaSpade) return + + if (lastSpadeUse.passedSince() > 5.seconds) { + lastSpadeUse = SimpleTimeMark.now() + foundGuess = false + } + } + + @SubscribeEvent + fun onBurrowGuess(event: BurrowGuessEvent) { + foundGuess = true + + if (hasSetToggleMusic) { + ChatUtils.chat("Toggling the hypixel music has worked, good job!") + } else if (hasSetParticleQuality) { + ChatUtils.chat("Changing the particle qualilty has worked, good job!") + } + + hasSetParticleQuality = false + hasSetToggleMusic = false + errorCounter = 0 + } + + private fun isEnabled() = DianaAPI.isDoingDiana() +} 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 29936f586..c1485bcad 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 @@ -14,8 +14,8 @@ import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.EntityMoveEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.event.diana.DianaAPI.isDianaSpade import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt import at.hannibal2.skyhanni.utils.BlockUtils.isInLoadedChunk @@ -88,12 +88,9 @@ object GriffinBurrowHelper { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - if (!event.repeatSeconds(1)) return - update() - loadTestGriffinSpots() } @@ -203,7 +200,9 @@ object GriffinBurrowHelper { GriffinBurrowParticleFinder.reset() BurrowWarpHelper.currentWarp = null - update() + if (isEnabled()) { + update() + } } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt b/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt index a2328297d..10ef1f737 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt @@ -54,6 +54,10 @@ object HypixelCommands { send("party transfer $player") } + fun particleQuality(quality: String) { + send("pq $quality") + } + fun partyAllInvite() { send("party settings allinvite") } |