From 55ed9131598f5f743b781cf95b39fa0a87a3177e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Mon, 28 Oct 2024 19:28:51 +0100 Subject: Fix: Carnival Area (#2843) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/events/skyblock/AreaChangeEvents.kt | 2 +- .../hannibal2/skyhanni/features/misc/IslandAreas.kt | 21 +++++++++++++-------- .../java/at/hannibal2/skyhanni/test/DebugCommand.kt | 5 ++++- .../skyhanni/test/graph/GraphEditorBugFinder.kt | 4 ++-- 4 files changed, 20 insertions(+), 12 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 340187030..6683fa69a 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/skyblock/AreaChangeEvents.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/skyblock/AreaChangeEvents.kt @@ -4,4 +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() +class GraphAreaChangeEvent(val area: String, val previousArea: String?, val onlyInternal: Boolean) : SkyHanniEvent() 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 6c0884fc3..2eeaef2f3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt @@ -53,7 +53,7 @@ object IslandAreas { display = null targetNode = null hasMoved = true - updateArea("no_area") + updateArea("no_area", onlyInternal = true) } fun nodeMoved() { @@ -162,10 +162,11 @@ object IslandAreas { val distance = difference.roundTo(0).toInt() val text = "$coloredName§7: §e$distance$suffix" + val isConfigVisible = node.getAreaTag(useConfig = true) != null if (!foundCurrentArea) { foundCurrentArea = true - val inAnArea = name != "no_area" + val inAnArea = name != "no_area" && isConfigVisible if (config.pathfinder.includeCurrentArea.get()) { if (inAnArea) { addSearchString("§eCurrent area: $coloredName") @@ -173,13 +174,14 @@ object IslandAreas { addSearchString("§7Not in an area.") } } - updateArea(name) + updateArea(name, onlyInternal = !isConfigVisible) addSearchString("§eAreas nearby:") continue } if (name == "no_area") continue + if (!isConfigVisible) continue foundAreas++ add( @@ -221,11 +223,11 @@ object IslandAreas { } } - private fun updateArea(name: String) { + private fun updateArea(name: String, onlyInternal: Boolean) { if (name != currentAreaName) { val oldArea = currentAreaName currentAreaName = name - GraphAreaChangeEvent(name, oldArea).post() + GraphAreaChangeEvent(name, oldArea, onlyInternal).post() } } @@ -233,6 +235,8 @@ object IslandAreas { fun onAreaChange(event: GraphAreaChangeEvent) { val name = event.area val inAnArea = name != "no_area" + // when this is a small area and small areas are disabled via config + if (event.onlyInternal) return if (inAnArea && config.enterTitle) { LorenzUtils.sendTitle("§aEntered $name!", 3.seconds) } @@ -247,7 +251,8 @@ object IslandAreas { if (name == currentAreaName) continue if (name == "no_area") continue val position = node.position - val color = node.getAreaTag()?.color?.getChatColor().orEmpty() + val areaTag = node.getAreaTag(useConfig = true) ?: continue + val color = areaTag.color.getChatColor() if (!position.canBeSeen(40.0)) return event.drawDynamicText(position, color + name, 1.5) } @@ -269,8 +274,8 @@ object IslandAreas { private val allAreas = listOf(GraphNodeTag.AREA, GraphNodeTag.SMALL_AREA) private val onlyLargeAreas = listOf(GraphNodeTag.AREA) - fun GraphNode.getAreaTag(ignoreConfig: Boolean = false): GraphNodeTag? = tags.firstOrNull { - it in (if (config.includeSmallAreas || ignoreConfig) allAreas else onlyLargeAreas) + fun GraphNode.getAreaTag(useConfig: Boolean = false): GraphNodeTag? = tags.firstOrNull { + it in (if (config.includeSmallAreas || !useConfig) allAreas else onlyLargeAreas) } private fun setTarget(node: GraphNode) { diff --git a/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt index d75b5abc6..5b1a48d06 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.repo.RepoManager import at.hannibal2.skyhanni.data.repo.RepoManager.Companion.hasDefaultSettings import at.hannibal2.skyhanni.events.DebugDataCollectEvent +import at.hannibal2.skyhanni.features.misc.IslandAreas import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.OSUtils @@ -127,7 +128,9 @@ object DebugCommand { event.addIrrelevant { add("on Hypixel SkyBlock") add("skyBlockIsland: ${LorenzUtils.skyBlockIsland}") - add("skyBlockArea: '${LorenzUtils.skyBlockArea}'") + add("skyBlockArea:") + add(" scoreboard: '${LorenzUtils.skyBlockArea}'") + add(" graph network: '${IslandAreas.currentAreaName}'") add("isOnAlphaServer: '${LorenzUtils.isOnAlphaServer}'") } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/graph/GraphEditorBugFinder.kt b/src/main/java/at/hannibal2/skyhanni/test/graph/GraphEditorBugFinder.kt index ca65ae87f..982fb12c5 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/graph/GraphEditorBugFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/graph/GraphEditorBugFinder.kt @@ -43,7 +43,7 @@ object GraphEditorBugFinder { val nearestArea = mutableMapOf() for (node in nodes) { - val pathToNearestArea = GraphUtils.findFastestPath(node) { it.getAreaTag(ignoreConfig = true) != null }?.first + val pathToNearestArea = GraphUtils.findFastestPath(node) { it.getAreaTag() != null }?.first if (pathToNearestArea == null) { continue } @@ -56,7 +56,7 @@ object GraphEditorBugFinder { for (neighbour in node.neighbours.keys) { val neighbouringAreaNode = nearestArea[neighbour]?.name ?: continue if (neighbouringAreaNode == areaNode) continue - if ((null == node.getAreaTag(ignoreConfig = true))) { + if ((null == node.getAreaTag())) { bugs++ errorsInWorld[node] = "§cConflicting areas $areaNode and $neighbouringAreaNode" } -- cgit