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

Fix: Anniversary Custom Scoreboard #2058

Merged
merged 4 commits into from
Jun 12, 2024
Merged
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 @@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive
object ConfigUpdaterMigrator {

val logger = LorenzLogger("ConfigMigration")
const val CONFIG_VERSION = 49
const val CONFIG_VERSION = 50
fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? {
if (chain.isEmpty()) return this
if (this !is JsonObject) return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ object CustomScoreboard {

newArray
}
event.transform(50, "$displayPrefix.events.eventEntries") { element ->
val array = element.asJsonArray
array.add(JsonPrimitive(ScoreboardEvents.ANNIVERSARY.name))
array
}

event.move(43, "$displayPrefix.alignment.alignRight", "$displayPrefix.alignment.horizontalAlignment") {
JsonPrimitive(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ enum class ScoreboardEvents(
::getRedstoneShowWhen,
"§e§l⚡ §cRedstone: §e§b7%"
),
ANNIVERSARY(
::getAnniversaryLines,
::getAnniversaryShowWhen,
"§d5th Anniversary§f 167:59:54",
),
;

override fun toString() = configLine
Expand Down Expand Up @@ -390,7 +395,7 @@ private fun getActiveEventLine(): List<String> {

// Some Active Events are better not shown from the tablist,
// but from other locations like the scoreboard
val blockedEvents = listOf("Spooky Festival")
val blockedEvents = listOf("Spooky Festival", "5th SkyBlock Anniversary")
if (blockedEvents.contains(currentActiveEvent.removeColor())) return emptyList()

val currentActiveEventTime = TabListData.getTabList().firstOrNull { SbPattern.eventTimeEndsPattern.matches(it) }
Expand Down Expand Up @@ -529,3 +534,7 @@ private fun getQueueShowWhen(): Boolean = SbPattern.queuePattern.anyMatches(getS
private fun getRedstoneLines(): List<String> = listOf(getSbLines().first { SbPattern.redstonePattern.matches(it) })

private fun getRedstoneShowWhen(): Boolean = SbPattern.redstonePattern.anyMatches(getSbLines())

private fun getAnniversaryLines() = listOf(getSbLines().first { SbPattern.anniversaryPattern.matches(it) })

private fun getAnniversaryShowWhen(): Boolean = SbPattern.anniversaryPattern.anyMatches(getSbLines())
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,15 @@ object ScoreboardPattern {
)
val queuePositionPattern by miscSb.pattern(
"queueposition",
"Position: (?:§.)*#\\d+ (?:§.)*Since: (?:§.)*.*"
"Position: (?:§.)*#\\d+ (?:§.)*Since: (?:§.)*.*",
)

/**
* REGEX-TEST: §d5th Anniversary§f 167:59:54
*/
val anniversaryPattern by miscSb.pattern(
"anniversary",
"§d\\d+(?:st|nd|rd|th) Anniversary§f (?:\\d|:)+",
)

// this thirdObjectiveLinePattern includes all those weird objective lines that go into a third scoreboard line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ object UnknownLinesHandler {
SbPattern.slayerQuestPattern,
SbPattern.essencePattern,
SbPattern.redstonePattern,
SbPattern.anniversaryPattern,
SbPattern.visitingPattern,
SbPattern.flightDurationPattern,
SbPattern.dojoChallengePattern,
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ object CollectionUtils {
return newList
}

/**
* This does not work inside a [buildList] block
hannibal002 marked this conversation as resolved.
Show resolved Hide resolved
*/
fun List<String>.addIfNotNull(element: String?) = element?.let { plus(it) } ?: this

fun <K, V> Map<K, V>.editCopy(function: MutableMap<K, V>.() -> Unit) =
Expand Down
Loading