diff options
author | J10a1n15 <45315647+j10a1n15@users.noreply.github.com> | 2024-05-04 03:35:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-04 03:35:38 +0200 |
commit | d8f1a2417cc48b9bfd3c9e75eff0bfc1c0d33a30 (patch) | |
tree | bc0f82ed32ecbfcc16ff195bfe719d11ae53f76f /src/main/java/at/hannibal2/skyhanni | |
parent | 2ca66dc5815810b7589ff915b300bd0ccd628b73 (diff) | |
download | skyhanni-d8f1a2417cc48b9bfd3c9e75eff0bfc1c0d33a30.tar.gz skyhanni-d8f1a2417cc48b9bfd3c9e75eff0bfc1c0d33a30.tar.bz2 skyhanni-d8f1a2417cc48b9bfd3c9e75eff0bfc1c0d33a30.zip |
Improvement: Add Incoming Tablist Event to Custom Scoreboard (#1666)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt | 36 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt | 4 |
2 files changed, 33 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt index a6e3ca165..4da038695 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt @@ -158,7 +158,12 @@ enum class ScoreboardEvents( ACTIVE_TABLIST_EVENTS( ::getActiveEventLine, ::getActiveEventShowWhen, - "§7(All Active Tablist Events)" + "§7(All Active Tablist Events)\n§dHoppity's Hunt\n §fEnds in: §e26h" + ), + STARTING_SOON_TABLIST_EVENTS( + ::getSoonEventLine, + ::getSoonEventShowWhen, + "§7(All Starting Soon Tablist Events)\n§6Mining Fiesta\n §fStarts in: §e52min" ), REDSTONE( ::getRedstoneLines, @@ -369,26 +374,43 @@ private fun getSpookyLines() = buildList { private fun getSpookyShowWhen(): Boolean = getSbLines().any { ScoreboardPattern.spookyPattern.matches(it) } -private fun getActiveEventLine(): List<String> { - val currentActiveEvent = TabListData.getTabList().firstOrNull { SbPattern.eventNamePattern.matches(it) } +private fun getTablistEvent(): String? = + TabListData.getTabList().firstOrNull { SbPattern.eventNamePattern.matches(it) } ?.let { SbPattern.eventNamePattern.matchMatcher(it) { group("name") } } - val currentActiveEventEndsIn = TabListData.getTabList().firstOrNull { SbPattern.eventTimeEndsPattern.matches(it) } + +private fun getActiveEventLine(): List<String> { + val currentActiveEvent = getTablistEvent() ?: return emptyList() + val currentActiveEventTime = TabListData.getTabList().firstOrNull { SbPattern.eventTimeEndsPattern.matches(it) } ?.let { SbPattern.eventTimeEndsPattern.matchMatcher(it) { group("time") } } - return listOf("$currentActiveEvent $currentActiveEventEndsIn") + return listOf(currentActiveEvent, " Ends in: §e$currentActiveEventTime") } private fun getActiveEventShowWhen(): Boolean = - TabListData.getTabList().any { SbPattern.eventNamePattern.matches(it) } && - TabListData.getTabList().any { SbPattern.eventTimeEndsPattern.matches(it) } + getTablistEvent() != null && TabListData.getTabList().any { SbPattern.eventTimeEndsPattern.matches(it) } + +private fun getSoonEventLine(): List<String> { + val soonActiveEvent = getTablistEvent() ?: return emptyList() + val soonActiveEventTime = TabListData.getTabList().firstOrNull { SbPattern.eventTimeEndsPattern.matches(it) } + ?.let { + SbPattern.eventTimeStartsPattern.matchMatcher(it) { + group("time") + } + } + + return listOf(soonActiveEvent, " Starts in: §e$soonActiveEventTime") +} + +private fun getSoonEventShowWhen(): Boolean = + getTablistEvent() != null && TabListData.getTabList().any { SbPattern.eventTimeStartsPattern.matches(it) } private fun getBroodmotherLines(): List<String> = listOf(getSbLines().first { SbPattern.broodmotherPattern.matches(it) }) 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 fd15e2131..d73525fc3 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 @@ -446,4 +446,8 @@ object ScoreboardPattern { "eventtime", "^\\s+Ends In: §r§e(?<time>.*)$" ) + val eventTimeStartsPattern by tablistGroup.pattern( + "eventtimestarts", + "^\\s+Starts In: §r§e(?<time>.*)$" + ) } |