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 a3b3652b2815..6562edaf3167 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 @@ -632,17 +632,21 @@ private fun getCookieShowWhen(): Boolean { } private fun getObjectiveDisplayPair() = buildList { - val objective = - ScoreboardData.sidebarLinesFormatted.first { ScoreboardPattern.objectivePattern.matches(it) } + val formattedLines = ScoreboardData.sidebarLinesFormatted + val objective = formattedLines.firstOrNull { ScoreboardPattern.objectivePattern.matches(it) } + if (objective != null) { + add(objective to HorizontalAlignment.LEFT) - add(objective to HorizontalAlignment.LEFT) - add((ScoreboardData.sidebarLinesFormatted.nextAfter(objective) ?: "") to HorizontalAlignment.LEFT) + val secondLine = formattedLines.nextAfter(objective) ?: "" + add(secondLine to HorizontalAlignment.LEFT) - if (ScoreboardData.sidebarLinesFormatted.any { ScoreboardPattern.thirdObjectiveLinePattern.matches(it) }) { - add( - (ScoreboardData.sidebarLinesFormatted.nextAfter(objective, 2) - ?: "Second objective here") to HorizontalAlignment.LEFT, - ) + formattedLines.nextAfter(objective, 2)?.let { + if (ScoreboardPattern.thirdObjectiveLinePattern.matches(it)) add(it to HorizontalAlignment.LEFT) + } + + formattedLines.nextAfter(objective, 3)?.let { + if (ScoreboardPattern.thirdObjectiveLinePattern.matches(it)) add(it to HorizontalAlignment.LEFT) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt index 62b282b37cbc..d9126ef44770 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt @@ -153,10 +153,11 @@ object ScoreboardPattern { /** * REGEX-TEST: Submerges In: §e01m 00s + * REGEX-TEST: Submerges In: §e??? */ val submergesPattern by kuudraSb.pattern( "submerges", - "(?:§.)*Submerges In: (?:§.)*[\\w\\s]+", + "(?:§.)*Submerges In: (?:§.)*[\\w\\s?]+", ) // farming @@ -392,7 +393,10 @@ object ScoreboardPattern { "§d\\d+(?:st|nd|rd|th) Anniversary§f (?:\\d|:)+", ) - // this thirdObjectiveLinePattern includes all those weird objective lines that go into a third scoreboard line + // this thirdObjectiveLinePattern includes all those weird objective lines that go into a third (and fourth) scoreboard line + /** + * REGEX-TEST: §eProtect Elle §7(§a98%§7) + */ val thirdObjectiveLinePattern by miscSb.pattern( "thirdobjectiveline", "(\\s*§.\\(§.\\w+§./§.\\w+§.\\)|§f Mages.*|§f Barbarians.*|§edefeat Kuudra|§eand stun him)", 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 a38b52d788bc..bbae099d6b7e 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 @@ -142,16 +142,17 @@ object UnknownLinesHandler { } /** - * remove known text + * Remove Known Text **/ - // remove objectives - val objectiveLine = sidebarLines.firstOrNull { SbPattern.objectivePattern.matches(it) } - ?: "Objective" - unknownLines = unknownLines.filter { sidebarLines.nextAfter(objectiveLine) != it } - // TODO create function - unknownLines = unknownLines.filter { - sidebarLines.nextAfter(objectiveLine, 2) != it && - !SbPattern.thirdObjectiveLinePattern.matches(it) + // Remove objectives + val objectiveLine = sidebarLines.firstOrNull { SbPattern.objectivePattern.matches(it) } ?: "Objective" + + unknownLines = unknownLines.filter { line -> + val nextLine = sidebarLines.nextAfter(objectiveLine) + val secondNextLine = sidebarLines.nextAfter(objectiveLine, 2) + val thirdNextLine = sidebarLines.nextAfter(objectiveLine, 3) + + line != nextLine && line != secondNextLine && line != thirdNextLine && !SbPattern.thirdObjectiveLinePattern.matches(line) } // Remove jacobs contest