aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt
blob: e15190864f49f606b216f5effd0c8aa9e384038c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.events.LorenzActionBarEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

object ActionBarStatsData {
    private val patterns = mapOf(
        "health" to "§c(?<health>[\\d,]+)/[\\d,]+❤.*".toPattern(),
        "defense" to ".*§a(?<defense>[\\d,]+)§a❈.*".toPattern(),
        "mana" to ".*§b(?<mana>[\\d,]+)/[\\d,]+✎.*".toPattern(),
        "riftTime" to "§[a7](?<riftTime>[\\dms ]+)ф.*".toPattern(),
    )

    var groups = mutableMapOf("health" to "", "riftTime" to "", "defense" to "", "mana" to "")

    @SubscribeEvent
    fun onActionBar(event: LorenzActionBarEvent) {
        if (!LorenzUtils.inSkyBlock) return

        for ((groupName, pattern) in patterns) {
            pattern.matchMatcher(event.message) {
                groups[groupName] = group(groupName)
            }
        }
    }
}