Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend: Active Custom Scoreboard Patterns #2927

Open
wants to merge 6 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.renderables.Renderable
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Pattern
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds

Expand All @@ -52,6 +53,9 @@ object CustomScoreboard {
var currentIslandEvents = listOf<ScoreboardEvent>()
private set

var activePatterns = listOf<Pattern>()
private set

private const val GUI_NAME = "Custom Scoreboard"

private var nextScoreboardUpdate = SimpleTimeMark.farFuture()
Expand Down Expand Up @@ -205,6 +209,14 @@ object CustomScoreboard {
private fun updateIslandEntries() {
currentIslandEntries = config.scoreboardEntries.get().map { it.element }.filter { it.showIsland() }
currentIslandEvents = eventsConfig.eventEntries.get().map { it.event }.filter { it.showIsland() }

activePatterns = ScoreboardConfigElement.entries
.filter {
it.element.showIsland()
}
.flatMap {
it.element.elementPatterns
}.distinct()
}

@SubscribeEvent
Expand All @@ -220,6 +232,9 @@ object CustomScoreboard {
add("Custom Scoreboard Events:")
addAll(formatEntriesDebug(eventsConfig.eventEntries.get().map { it.name to it.event }))

add("Active Patterns:")
activePatterns.forEach { add(" $it") }

allUnknownLines.takeIfNotEmpty()?.let { set ->
add("Recent Unknown Lines:")
set.forEach { add(" ${it.line}") }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
package at.hannibal2.skyhanni.features.gui.customscoreboard

import at.hannibal2.skyhanni.data.BitsAPI
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.data.MiningAPI
import at.hannibal2.skyhanni.data.PurseAPI
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.features.combat.SpidersDenAPI
import at.hannibal2.skyhanni.features.misc.ServerRestartTitle
import at.hannibal2.skyhanni.features.rift.area.stillgorechateau.RiftBloodEffigies
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
Expand Down Expand Up @@ -39,127 +33,15 @@ object UnknownLinesHandler {
/**
* Remove known lines with patterns
**/
private val patternsToExclude = mutableListOf(
PurseAPI.coinsPattern,
SbPattern.motesPattern,
BitsAPI.bitsScoreboardPattern,
SbPattern.heatPattern,
SbPattern.copperPattern,
SbPattern.locationPattern,
SbPattern.lobbyCodePattern,
SbPattern.datePattern,
SbPattern.timePattern,
SbPattern.footerPattern,
SbPattern.yearVotesPattern,
SbPattern.votesPattern,
SbPattern.waitingForVotePattern,
SbPattern.northstarsPattern,
SbPattern.profileTypePattern,
SbPattern.autoClosingPattern,
SbPattern.startingInPattern,
SbPattern.timeElapsedPattern,
SbPattern.instanceShutdownPattern,
SbPattern.keysPattern,
SbPattern.clearedPattern,
SbPattern.soloPattern,
SbPattern.teammatesPattern,
SbPattern.floor3GuardiansPattern,
SbPattern.m7dragonsPattern,
SbPattern.wavePattern,
SbPattern.tokensPattern,
SbPattern.submergesPattern,
SbPattern.medalsPattern,
SbPattern.lockedPattern,
SbPattern.cleanUpPattern,
SbPattern.pastingPattern,
SbPattern.peltsPattern,
SbPattern.mobLocationPattern,
SbPattern.jacobsContestPattern,
SbPattern.plotPattern,
SbPattern.powderGreedyPattern,
SbPattern.windCompassPattern,
SbPattern.windCompassArrowPattern,
SbPattern.miningEventPattern,
SbPattern.miningEventZonePattern,
SbPattern.raffleUselessPattern,
SbPattern.raffleTicketsPattern,
SbPattern.rafflePoolPattern,
SbPattern.mithrilUselessPattern,
SbPattern.mithrilRemainingPattern,
SbPattern.mithrilYourMithrilPattern,
SbPattern.nearbyPlayersPattern,
SbPattern.uselessGoblinPattern,
SbPattern.remainingGoblinPattern,
SbPattern.yourGoblinKillsPattern,
SbPattern.magmaBossPattern,
SbPattern.damageSoakedPattern,
SbPattern.killMagmasPattern,
SbPattern.killMagmasDamagedSoakedBarPattern,
SbPattern.reformingPattern,
SbPattern.bossHealthPattern,
SbPattern.bossHealthBarPattern,
SpidersDenAPI.broodmotherPattern,
SbPattern.bossHPPattern,
SbPattern.bossDamagePattern,
SbPattern.slayerQuestPattern,
SbPattern.essencePattern,
SbPattern.redstonePattern,
SbPattern.anniversaryPattern,
SbPattern.visitingPattern,
SbPattern.flightDurationPattern,
SbPattern.dojoChallengePattern,
SbPattern.dojoDifficultyPattern,
SbPattern.dojoPointsPattern,
SbPattern.dojoTimePattern,
SbPattern.objectivePattern,
ServerRestartTitle.restartingGreedyPattern,
SbPattern.travelingZooPattern,
SbPattern.newYearPattern,
SbPattern.spookyPattern,
SbPattern.winterEventStartPattern,
SbPattern.winterNextWavePattern,
SbPattern.winterWavePattern,
SbPattern.winterMagmaLeftPattern,
SbPattern.winterTotalDmgPattern,
SbPattern.winterCubeDmgPattern,
SbPattern.riftDimensionPattern,
RiftBloodEffigies.heartsPattern,
SbPattern.wtfAreThoseLinesPattern,
SbPattern.timeLeftPattern,
SbPattern.darkAuctionCurrentItemPattern,
MiningAPI.coldPattern,
SbPattern.riftHotdogTitlePattern,
SbPattern.riftHotdogEatenPattern,
SbPattern.mineshaftNotStartedPattern,
SbPattern.queuePattern,
SbPattern.queueTierPattern,
SbPattern.queuePositionPattern,
SbPattern.fortunateFreezingBonusPattern,
SbPattern.riftAveikxPattern,
SbPattern.riftHayEatenPattern,
SbPattern.fossilDustPattern,
SbPattern.cluesPattern,
SbPattern.barryProtestorsQuestlinePattern,
SbPattern.barryProtestorsHandledPattern,
SbPattern.carnivalPattern,
SbPattern.carnivalTasksPattern,
SbPattern.carnivalTokensPattern,
SbPattern.carnivalFruitsPattern,
SbPattern.carnivalScorePattern,
SbPattern.carnivalCatchStreakPattern,
SbPattern.carnivalAccuracyPattern,
SbPattern.carnivalKillsPattern,
)
private var remoteOnlyPatternsAdded = false

fun handleUnknownLines() {
val sidebarLines = ScoreboardData.sidebarLinesFormatted

var unknownLines = sidebarLines.map { it.removeResets() }.filter { it.isNotBlank() }.filter { it.trim().length > 3 }

if (::remoteOnlyPatterns.isInitialized && !remoteOnlyPatternsAdded) {
val patternsToExclude = CustomScoreboard.activePatterns.toMutableList()

if (::remoteOnlyPatterns.isInitialized) {
patternsToExclude.addAll(remoteOnlyPatterns)
remoteOnlyPatternsAdded = true
}
unknownLines = unknownLines.filterNot { line ->
patternsToExclude.any { pattern -> pattern.matches(line) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard.elements
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.informationFilteringConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getElementsFromAny
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardLine
import java.util.regex.Pattern

abstract class ScoreboardElement {
/**
Expand All @@ -20,6 +21,8 @@ abstract class ScoreboardElement {

open fun showIsland(): Boolean = true

open val elementPatterns = emptyList<Pattern>()

// TODO: Add Hover and Clickable Feedback to Lines
// Suggestion: https://discord.com/channels/997079228510117908/1226508204762992733

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ object ScoreboardElementBits : ScoreboardElement() {

override val configLine = "Bits: §b59,264"

override val elementPatterns = listOf(BitsAPI.bitsScoreboardPattern)

override fun showIsland() = !inAnyIsland(IslandType.CATACOMBS, IslandType.KUUDRA_ARENA)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package at.hannibal2.skyhanni.features.gui.customscoreboard.elements

import at.hannibal2.skyhanni.data.BitsAPI
import at.hannibal2.skyhanni.data.MiningAPI
import at.hannibal2.skyhanni.data.PurseAPI
import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLine.Companion.getChunkedStats
import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLine.Companion.shouldShowChunkedStats
import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLine.Companion.showChunkedStatsIsland
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.chunkedConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern

// internal, widget and scoreboard
// a bit of everything
Expand All @@ -15,5 +19,10 @@ object ScoreboardElementChunkedStats : ScoreboardElement() {

override val configLine = "§652,763,737 §7| §d64,647 §7| §6249M\n§b59,264 §7| §c23,495 §7| §a57,873\n§c♨ 0 §7| §b0❄ §7| §d756"

override val elementPatterns = listOf(
PurseAPI.coinsPattern, ScoreboardPattern.motesPattern, BitsAPI.bitsScoreboardPattern,
ScoreboardPattern.copperPattern, ScoreboardPattern.heatPattern, MiningAPI.coldPattern, ScoreboardPattern.northstarsPattern,
)

override fun showIsland() = showChunkedStatsIsland()
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ object ScoreboardElementCold : ScoreboardElement() {

override val configLine = "Cold: §b0❄"

override val elementPatterns = listOf(MiningAPI.coldPattern)

override fun showIsland() = MiningAPI.inColdIsland()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.disp
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.informationFilteringConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.formatStringNum
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getCopper
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern

// scoreboard
// scoreboard update event
Expand All @@ -21,6 +22,8 @@ object ScoreboardElementCopper : ScoreboardElement() {

override val configLine = "Copper: §c23,495"

override val elementPatterns = listOf(ScoreboardPattern.copperPattern)

override fun showIsland() = GardenAPI.inGarden()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.features.gui.customscoreboard.elements

import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern
import at.hannibal2.skyhanni.utils.SkyBlockTime
import at.hannibal2.skyhanni.utils.TimeUtils.formatted

Expand All @@ -9,4 +10,6 @@ object ScoreboardElementDate : ScoreboardElement() {
override fun getDisplay() = SkyBlockTime.now().formatted(yearElement = false, hoursAndMinutesElement = false)

override val configLine = "Late Summer 11th"

override val elementPatterns = listOf(ScoreboardPattern.datePattern)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard.elements
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.currentIslandEvents
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.eventsConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getElementsFromAny
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardConfigEventElement
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardLine
import at.hannibal2.skyhanni.utils.CollectionUtils.takeIfNotEmpty

Expand All @@ -15,5 +16,8 @@ object ScoreboardElementEvents : ScoreboardElement() {

override val configLine = "§7Wide Range of Events\n§7(too much to show all)"

override val elementPatterns =
ScoreboardConfigEventElement.entries.filter { it.event.showIsland() }.flatMap { it.event.elementPatterns }

override fun getLines(): List<ScoreboardLine> = if (showWhen()) getElementsFromAny(getDisplay()) else listOf()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard.elements
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.displayConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardLine.Companion.align
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern

// internal
// update on config load
Expand All @@ -15,4 +16,6 @@ object ScoreboardElementFooter : ScoreboardElement() {
.map { it align displayConfig.titleAndFooter.alignFooter }

override val configLine = "§ewww.hypixel.net"

override val elementPatterns = listOf(ScoreboardPattern.footerPattern)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.data.MiningAPI
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.displayConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.informationFilteringConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getHeat
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern

// scoreboard
// scoreboard update event
Expand All @@ -20,5 +21,7 @@ object ScoreboardElementHeat : ScoreboardElement() {

override val configLine = "Heat: §c♨ 14"

override val elementPatterns = listOf(ScoreboardPattern.heatPattern)

override fun showIsland() = MiningAPI.inCrystalHollows()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.data.DateFormat
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern

// internal
// update on island change and every second while in dungeons
Expand All @@ -15,4 +16,6 @@ object ScoreboardElementLobbyCode : ScoreboardElement() {
}

override val configLine = "§7${DateFormat.US_SLASH_MMDDYYYY} §8mega77CK"

override val elementPatterns = listOf(ScoreboardPattern.lobbyCodePattern)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ object ScoreboardElementLocation : ScoreboardElement() {
)

override val configLine = "§7⏣ §bVillage"

override val elementPatterns = listOf(ScoreboardPattern.locationPattern)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.disp
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.informationFilteringConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.formatStringNum
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getMotes
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern
import at.hannibal2.skyhanni.features.rift.RiftAPI

// scoreboard
Expand All @@ -21,5 +22,7 @@ object ScoreboardElementMotes : ScoreboardElement() {

override val configLine = "Motes: §d64,647"

override val elementPatterns = listOf(ScoreboardPattern.motesPattern)

override fun showIsland() = RiftAPI.inRift()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.disp
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.informationFilteringConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.formatStringNum
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getNorthStars
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern

// scoreboard
// scoreboard update event
Expand All @@ -21,5 +22,7 @@ object ScoreboardElementNorthStars : ScoreboardElement() {

override val configLine = "North Stars: §d756"

override val elementPatterns = listOf(ScoreboardPattern.northstarsPattern)

override fun showIsland() = WinterAPI.inWorkshop()
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ object ScoreboardElementObjective : ScoreboardElement() {
}

override val configLine = "Objective:\n§eStar SkyHanni on Github"

override val elementPatterns = listOf(ScoreboardPattern.objectivePattern)
}

// click: open the objective page (i think a command should exist)
Loading
Loading