Skip to content

Commit

Permalink
Fix: Mineshaft roomId in Custom Scoreboard (#2946)
Browse files Browse the repository at this point in the history
  • Loading branch information
j10a1n15 authored Nov 20, 2024
1 parent 37a90c1 commit 6602467
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.events.ServerBlockChangeEvent
import at.hannibal2.skyhanni.events.mining.OreMinedEvent
import at.hannibal2.skyhanni.events.player.PlayerDeathEvent
import at.hannibal2.skyhanni.events.skyblock.ScoreboardAreaChangeEvent
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.dungeonRoomPattern
import at.hannibal2.skyhanni.features.mining.OreBlock
import at.hannibal2.skyhanni.features.mining.isTitanium
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
Expand Down Expand Up @@ -152,6 +153,9 @@ object MiningAPI {
var cold: Int = 0
private set

var mineshaftRoomId: String? = null
private set

var lastColdUpdate = SimpleTimeMark.farPast()
private set
var lastColdReset = SimpleTimeMark.farPast()
Expand Down Expand Up @@ -188,6 +192,14 @@ object MiningAPI {

@SubscribeEvent
fun onScoreboardChange(event: ScoreboardUpdateEvent) {
if (!inCustomMiningIsland()) return

dungeonRoomPattern.firstMatcher(event.added) {
mineshaftRoomId = group("roomId")
} ?: run {
mineshaftRoomId = null
}

val newCold = coldPattern.firstMatcher(event.added) {
group("cold").toInt().absoluteValue
} ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ object DungeonAPI {
/**
* REGEX-TEST: §711/15/24 §8m4F 830,-420
*/
private val dungeonRoomPattern by patternGroup.pattern(
val dungeonRoomPattern by patternGroup.pattern(
"room",
"§7\\d+/\\d+/\\d+ §\\w+ (?<roomId>[\\w,-]+)",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard.elements

import at.hannibal2.skyhanni.data.DateFormat
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.data.MiningAPI
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard

// internal
// update on island change and every second while in dungeons
object ScoreboardElementLobbyCode : ScoreboardElement() {
override fun getDisplay() = buildString {
if (CustomScoreboard.displayConfig.dateInLobbyCode) append("§7${CustomScoreboard.displayConfig.dateFormat} ")
HypixelData.serverId?.let { append("§8$it") }
DungeonAPI.roomId?.let { append(" §8$it") }
}
if (CustomScoreboard.displayConfig.dateInLobbyCode) append("§7${CustomScoreboard.displayConfig.dateFormat}")
listOfNotNull(
HypixelData.serverId,
DungeonAPI.roomId,
MiningAPI.mineshaftRoomId,
).forEach { append(" §8$it") }
}.trim()

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

0 comments on commit 6602467

Please sign in to comment.