From ed9a2aa7fafaf0d987d34f8eea529a206d535747 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:27:06 +0200 Subject: Future Fix: CustomeScoreboard UnkownLinesHandler auto adds patterns from the repo (#2068) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../gui/customscoreboard/ScoreboardPattern.kt | 235 +++++++++++---------- .../gui/customscoreboard/UnknownLinesHandler.kt | 57 +++-- 2 files changed, 156 insertions(+), 136 deletions(-) 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 81e8b2382..984e91750 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 @@ -1,44 +1,51 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard +import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object ScoreboardPattern { - val group = RepoPattern.group("features.gui.customscoreboard") + private val group = RepoPattern.group("features.gui.customscoreboard") // Stats from the scoreboard - private val scoreboardGroup = group.group("scoreboard") + private val scoreboardGroup by group.exclusiveGroup("scoreboard") + + @SubscribeEvent + fun onRepositoryReload(event: RepositoryReloadEvent) { + UnknownLinesHandler.remoteOnlyPatterns = scoreboardGroup.getUnusedPatterns().toTypedArray() + } // main scoreboard private val mainSb = scoreboardGroup.group("main") val motesPattern by mainSb.pattern( "motes", - "^(§.)*Motes: (§.)*(?[\\d,]+).*$" + "^(§.)*Motes: (§.)*(?[\\d,]+).*$", ) val heatPattern by mainSb.pattern( "heat", - "^Heat: (?.*)$" + "^Heat: (?.*)$", ) // this line is weird (either text or number), ill leave it as is; it even has different colors? val coldPattern by mainSb.pattern( "cold", - "^(?:§.)*Cold: §.(?-?\\d+)❄$" + "^(?:§.)*Cold: §.(?-?\\d+)❄$", ) val copperPattern by mainSb.pattern( "copper", - "^(§.)*Copper: (§.)*(?[\\d,]+).*$" + "^(§.)*Copper: (§.)*(?[\\d,]+).*$", ) val locationPattern by mainSb.pattern( "location", - "^\\s*(?(§7⏣|§5ф) .*)$" + "^\\s*(?(§7⏣|§5ф) .*)$", ) val lobbyCodePattern by mainSb.pattern( "lobbycode", - "^\\s*§.((\\d{2}/\\d{2}/\\d{2})|Server closing: [\\d:]+) §8(?.*)\$" + "^\\s*§.((\\d{2}/\\d{2}/\\d{2})|Server closing: [\\d:]+) §8(?.*)\$", ) val datePattern by mainSb.pattern( "date", - "^\\s*(Late |Early )?(Spring|Summer|Autumn|Winter) \\d{1,2}(st|nd|rd|th)?.*" + "^\\s*(Late |Early )?(Spring|Summer|Autumn|Winter) \\d{1,2}(st|nd|rd|th)?.*", ) /** @@ -47,135 +54,135 @@ object ScoreboardPattern { */ val timePattern by mainSb.pattern( "time", - "^\\s*§7\\d{1,2}:\\d{2}(?:am|pm)\\s*(?(§b☽|§e☀|§.⚡|§.☔))?.*$" + "^\\s*§7\\d{1,2}:\\d{2}(?:am|pm)\\s*(?(§b☽|§e☀|§.⚡|§.☔))?.*$", ) val footerPattern by mainSb.pattern( "footer", - "§e(www|alpha).hypixel.net\$" + "§e(www|alpha).hypixel.net\$", ) val yearVotesPattern by mainSb.pattern( "yearvotes", - "(?^§6Year \\d+ Votes\$)" + "(?^§6Year \\d+ Votes\$)", ) val votesPattern by mainSb.pattern( "votes", - "(?§[caebd]\\|+(§f)?\\|+ §(.+)$)" + "(?§[caebd]\\|+(§f)?\\|+ §(.+)$)", ) val waitingForVotePattern by mainSb.pattern( "waitingforvote", - "(§7Waiting for|§7your vote\\.\\.\\.)$" + "(§7Waiting for|§7your vote\\.\\.\\.)$", ) val northstarsPattern by mainSb.pattern( "northstars", - "North Stars: §d(?[\\w,]+).*$" + "North Stars: §d(?[\\w,]+).*$", ) val profileTypePattern by mainSb.pattern( "profiletype", - "^\\s*(§7♲ §7Ironman|§a☀ §aStranded|§.Ⓑ §.Bingo).*$" + "^\\s*(§7♲ §7Ironman|§a☀ §aStranded|§.Ⓑ §.Bingo).*$", ) val emptyLinesPattern by mainSb.pattern( "emptylines", - "^\\s*$" + "^\\s*$", ) // multi use private val multiUseSb = scoreboardGroup.group("multiuse") val autoClosingPattern by multiUseSb.pattern( "autoclosing", - "(§.)*Auto-closing in: §c(\\d{1,2}:)?\\d{1,2}$" + "(§.)*Auto-closing in: §c(\\d{1,2}:)?\\d{1,2}$", ) val startingInPattern by multiUseSb.pattern( "startingin", - "(§.)*Starting in: §.(\\d{1,2}:)?\\d{1,2}$" + "(§.)*Starting in: §.(\\d{1,2}:)?\\d{1,2}$", ) val timeElapsedPattern by multiUseSb.pattern( "timeelapsed", - "(§.)*Time Elapsed: (§.)*(?