diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-10-18 16:30:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-18 16:30:04 +0200 |
| commit | ead1f9ebf3882a6a65b6dd879d01c725c80f7e73 (patch) | |
| tree | 968caf9a006f11b36e94dd31853b64d2cf47c347 | |
| parent | cacff66c3d86b80f5868e70aad26eff41ad0092d (diff) | |
| download | SkyHanni-ead1f9ebf3882a6a65b6dd879d01c725c80f7e73.tar.gz SkyHanni-ead1f9ebf3882a6a65b6dd879d01c725c80f7e73.tar.bz2 SkyHanni-ead1f9ebf3882a6a65b6dd879d01c725c80f7e73.zip | |
Backend: GraphAreaChangeEvent (#2754)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
4 files changed, 24 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/skyblock/AreaChangeEvents.kt b/src/main/java/at/hannibal2/skyhanni/events/skyblock/AreaChangeEvents.kt index b262ea9fb..340187030 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/skyblock/AreaChangeEvents.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/skyblock/AreaChangeEvents.kt @@ -4,3 +4,4 @@ import at.hannibal2.skyhanni.api.event.SkyHanniEvent // Detect area changes by looking at the scoreboard. class ScoreboardAreaChangeEvent(val area: String, val previousArea: String?) : SkyHanniEvent() +class GraphAreaChangeEvent(val area: String, val previousArea: String?) : SkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt index fe14093ef..e0d3ba6d4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.combat.ghostcounter import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostCounterConfig.GhostDisplayEntry import at.hannibal2.skyhanni.data.IslandType @@ -11,11 +12,11 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.events.skyblock.GraphAreaChangeEvent import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData.Option import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData.Option.KILLS import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData.bestiaryData @@ -25,7 +26,6 @@ import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.isUsingCTGho import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.preFormat import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.prettyTime import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData -import at.hannibal2.skyhanni.features.misc.IslandAreas import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ChatUtils.chat @@ -345,9 +345,9 @@ object GhostCounter { } } - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - inMist = IslandAreas.currentAreaName == "The Mist" + @HandleEvent + fun onAreaChange(event: GraphAreaChangeEvent) { + inMist = event.area == "The Mist" } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt index 47ab47a38..562e67eb7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt @@ -1,10 +1,10 @@ package at.hannibal2.skyhanni.features.event.hoppity import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.features.misc.IslandAreas +import at.hannibal2.skyhanni.events.skyblock.GraphAreaChangeEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -58,9 +58,9 @@ object NucleusBarriersBox { ), } - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - inNucleus = IslandAreas.currentAreaName == "Crystal Nucleus" + @HandleEvent + fun onAreaChange(event: GraphAreaChangeEvent) { + inNucleus = event.area == "Crystal Nucleus" } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt index dfa60478a..2176fc2a0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.IslandGraphs import at.hannibal2.skyhanni.data.IslandGraphs.pathFind import at.hannibal2.skyhanni.data.model.Graph @@ -13,6 +14,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.skyblock.GraphAreaChangeEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString import at.hannibal2.skyhanni.utils.CollectionUtils.sorted @@ -171,10 +173,9 @@ object IslandAreas { } } if (name != currentAreaName) { - if (inAnArea && config.enterTitle) { - LorenzUtils.sendTitle("§aEntered $name!", 3.seconds) - } + val oldArea = currentAreaName currentAreaName = name + GraphAreaChangeEvent(name, oldArea).post() } addSearchString("§eAreas nearby:") @@ -223,6 +224,15 @@ object IslandAreas { } } + @HandleEvent + fun onAreaChange(event: GraphAreaChangeEvent) { + val name = event.area + val inAnArea = name != "no_area" + if (inAnArea && config.enterTitle) { + LorenzUtils.sendTitle("§aEntered $name!", 3.seconds) + } + } + @SubscribeEvent fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!LorenzUtils.inSkyBlock) return |
