diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-06-10 12:15:01 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-06-10 12:15:01 +0200 |
commit | 88a7b06169641bd447ab34e65d19dd73711bd253 (patch) | |
tree | 00d6d1de802ac61e0112c07cc837584996c9a27b /src/main/java/at | |
parent | 7d0875bf2218c9e03712f549baa6471221ff7140 (diff) | |
download | skyhanni-88a7b06169641bd447ab34e65d19dd73711bd253.tar.gz skyhanni-88a7b06169641bd447ab34e65d19dd73711bd253.tar.bz2 skyhanni-88a7b06169641bd447ab34e65d19dd73711bd253.zip |
Fixed broken wither impact message showing at the wrong time
Diffstat (limited to 'src/main/java/at')
3 files changed, 15 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt index 6b4adc54c..0d063146d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt @@ -28,6 +28,7 @@ object SlayerAPI { var isInSlayerArea = false private var latestSlayerCategory = "" private var latestProgressChangeTime = 0L + var latestWrongAreaWarning = 0L private var latestSlayerProgress = "" fun hasActiveSlayerQuest() = latestSlayerCategory != "" diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/DetectBrokenHyperion.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/DetectBrokenHyperion.kt index 53baff2f1..fe142046b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/DetectBrokenHyperion.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/DetectBrokenHyperion.kt @@ -5,8 +5,10 @@ import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.data.TitleUtils import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent +import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAbilityScrolls import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class DetectBrokenHyperion { @@ -20,6 +22,10 @@ class DetectBrokenHyperion { if (event.reason != PurseChangeCause.GAIN_MOB_KILL) return if (!SlayerAPI.hasActiveSlayerQuest()) return if (!SlayerAPI.isInSlayerArea) return + if (SlayerAPI.latestWrongAreaWarning + 5_000 > System.currentTimeMillis()) return + + val abilityScrolls = InventoryUtils.getItemInHand()?.getAbilityScrolls() ?: return + if (!abilityScrolls.contains("IMPLOSION_SCROLL")) return val diff = System.currentTimeMillis() - SlayerAPI.getLatestProgressChangeTime() logger.log("diff: $diff") diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt index 15062c24e..7a2c0d249 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.slayer import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ScoreboardData +import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.data.TitleUtils import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -28,7 +29,7 @@ class SlayerQuestWarning { @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { - if (!isEnabled()) return + if (!(LorenzUtils.inSkyBlock)) return val message = event.message @@ -53,8 +54,6 @@ class SlayerQuestWarning { needSlayerQuest = false } - //TODO hyp does no damage anymore - //TODO auto slayer disabled bc of no more money in bank or purse } @@ -65,7 +64,7 @@ class SlayerQuestWarning { @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { - if (!isEnabled()) return + if (!(LorenzUtils.inSkyBlock)) return if (dirtySidebar) { if (tick++ % 60 == 0) { @@ -118,8 +117,6 @@ class SlayerQuestWarning { @SubscribeEvent fun onWorldChange(event: WorldEvent.Load) { - if (!config.questWarning) return - if (!needSlayerQuest) { dirtySidebar = true } @@ -131,6 +128,7 @@ class SlayerQuestWarning { } private fun warn(titleMessage: String, chatMessage: String) { + if (!config.questWarning) return if (lastWarning + 10_000 > System.currentTimeMillis()) return lastWarning = System.currentTimeMillis() @@ -143,10 +141,10 @@ class SlayerQuestWarning { @SubscribeEvent fun onEntityHealthUpdate(event: EntityHealthUpdateEvent) { - if (!isEnabled()) return + if (!(LorenzUtils.inSkyBlock)) return val entity = event.entity - if (entity.getLorenzVec().distanceToPlayer() < 5) { + if (entity.getLorenzVec().distanceToPlayer() < 6) { if (isSlayerMob(entity)) { tryWarn() } @@ -162,6 +160,8 @@ class SlayerQuestWarning { if (slayerType != activeSlayer) { val activeSlayerName = activeSlayer.displayName val slayerName = slayerType.displayName + SlayerAPI.latestWrongAreaWarning = System.currentTimeMillis() + LorenzUtils.debug("set latestWrongAreaWarning!") warn( "Wrong Slayer!", "Wrong slayer selected! You have $activeSlayerName selected and are in the $slayerName area!" @@ -172,7 +172,4 @@ class SlayerQuestWarning { return slayerType.clazz.isInstance(entity) } - private fun isEnabled(): Boolean { - return LorenzUtils.inSkyBlock && config.questWarning - } }
\ No newline at end of file |