diff options
author | Empa <42304516+ItsEmpa@users.noreply.github.com> | 2024-06-20 23:19:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-20 23:19:23 +0200 |
commit | b4b0bf1e83a1f07927478ed7c8dcff10bdfa855e (patch) | |
tree | b97992a6d8792b5595c8b1b8e79862df3a8e178c /src/main/java/at/hannibal2 | |
parent | a4c24726296f98e525378aea5a768e693e0b3883 (diff) | |
download | skyhanni-b4b0bf1e83a1f07927478ed7c8dcff10bdfa855e.tar.gz skyhanni-b4b0bf1e83a1f07927478ed7c8dcff10bdfa855e.tar.bz2 skyhanni-b4b0bf1e83a1f07927478ed7c8dcff10bdfa855e.zip |
Fix: Unknown Lines Handler (#2119)
Co-authored-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt | 9 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt | 46 |
2 files changed, 28 insertions, 27 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt index b73df6f14..edabad06a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt @@ -29,6 +29,7 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.part import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.formatNum import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getGroupFromPattern import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.LorenzUtils.inAdvancedMiningIsland import at.hannibal2.skyhanni.utils.LorenzUtils.inAnyIsland @@ -47,14 +48,14 @@ import at.hannibal2.skyhanni.utils.TimeUtils.formatted import java.util.function.Supplier import kotlin.time.Duration.Companion.seconds -internal var confirmedUnknownLines = mutableListOf<String>() +internal var confirmedUnknownLines = listOf<String>() internal var unconfirmedUnknownLines = listOf<String>() -internal var unknownLinesSet = TimeLimitedSet<String>(2.seconds) { onRemoval(it) } +internal var unknownLinesSet = TimeLimitedSet<String>(1.seconds) { onRemoval(it) } private fun onRemoval(line: String) { - if (!unconfirmedUnknownLines.contains(line)) return + if (line !in unconfirmedUnknownLines) return unconfirmedUnknownLines = unconfirmedUnknownLines.filterNot { it == line } - confirmedUnknownLines.add(line) + confirmedUnknownLines = confirmedUnknownLines.editCopy { add(line) } if (!config.unknownLinesWarning) return val pluralize = pluralize(confirmedUnknownLines.size, "unknown line", withNumber = true) val message = "CustomScoreboard detected $pluralize" diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt index 9b82f9b6f..a38b52d78 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt @@ -19,7 +19,7 @@ object UnknownLinesHandler { fun handleUnknownLines() { val sidebarLines = ScoreboardData.sidebarLinesFormatted - unconfirmedUnknownLines = sidebarLines + var unknownLines = sidebarLines .map { it.removeResets() } .filter { it.isNotBlank() } .filter { it.trim().length > 3 } @@ -137,7 +137,7 @@ object UnknownLinesHandler { *remoteOnlyPatterns, ) - unconfirmedUnknownLines = unconfirmedUnknownLines.filterNot { line -> + unknownLines = unknownLines.filterNot { line -> patternsToExclude.any { pattern -> pattern.matches(line) } } @@ -147,16 +147,16 @@ object UnknownLinesHandler { // remove objectives val objectiveLine = sidebarLines.firstOrNull { SbPattern.objectivePattern.matches(it) } ?: "Objective" - unconfirmedUnknownLines = unconfirmedUnknownLines.filter { sidebarLines.nextAfter(objectiveLine) != it } + unknownLines = unknownLines.filter { sidebarLines.nextAfter(objectiveLine) != it } // TODO create function - unconfirmedUnknownLines = unconfirmedUnknownLines.filter { + unknownLines = unknownLines.filter { sidebarLines.nextAfter(objectiveLine, 2) != it && !SbPattern.thirdObjectiveLinePattern.matches(it) } // Remove jacobs contest - for (i in 1..3) - unconfirmedUnknownLines = unconfirmedUnknownLines.filter { + for (i in 1..3) { + unknownLines = unknownLines.filter { sidebarLines.nextAfter( sidebarLines.firstOrNull { line -> SbPattern.jacobsContestPattern.matches(line) @@ -164,10 +164,11 @@ object UnknownLinesHandler { i, ) != it } + } // Remove slayer - for (i in 1..2) - unconfirmedUnknownLines = unconfirmedUnknownLines.filter { + for (i in 1..2) { + unknownLines = unknownLines.filter { sidebarLines.nextAfter( sidebarLines.firstOrNull { line -> SbPattern.slayerQuestPattern.matches(line) @@ -175,9 +176,10 @@ object UnknownLinesHandler { i, ) != it } + } // remove trapper mob location - unconfirmedUnknownLines = unconfirmedUnknownLines.filter { + unknownLines = unknownLines.filter { sidebarLines.nextAfter( sidebarLines.firstOrNull { line -> SbPattern.mobLocationPattern.matches(line) @@ -186,7 +188,7 @@ object UnknownLinesHandler { } // da - unconfirmedUnknownLines = unconfirmedUnknownLines.filter { + unknownLines = unknownLines.filter { sidebarLines.nextAfter( sidebarLines.firstOrNull { line -> SbPattern.darkAuctionCurrentItemPattern.matches(line) @@ -197,19 +199,17 @@ object UnknownLinesHandler { /* * Handle broken scoreboard lines */ - confirmedUnknownLines.forEach { line -> - if (!unconfirmedUnknownLines.contains(line)) { - confirmedUnknownLines = confirmedUnknownLines.filterNot { it == line }.toMutableList() - unconfirmedUnknownLines = unconfirmedUnknownLines.filterNot { it == line } - } - } - unconfirmedUnknownLines.forEach { line -> - if (confirmedUnknownLines.contains(line)) { - unconfirmedUnknownLines = unconfirmedUnknownLines.filterNot { it == line } - } else if (!unknownLinesSet.contains(line)) { - ChatUtils.debug("Unknown Scoreboard line: '$line'") - unknownLinesSet.add(line) - } + confirmedUnknownLines = confirmedUnknownLines.filter { it in unknownLines } + + unknownLines = unknownLines.filter { it !in confirmedUnknownLines } + + unconfirmedUnknownLines = unknownLines + + unknownLines = unknownLines.filter { it !in unknownLinesSet } + + unknownLines.forEach { + ChatUtils.debug("Unknown Scoreboard line: '$it'") + unknownLinesSet.add(it) } } } |