Skip to content

Commit

Permalink
Creating and using GraphAreaChangeEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
hannibal002 committed Oct 18, 2024
1 parent f4fa81e commit 77751fa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 77751fa

Please sign in to comment.