aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt
blob: cddf83d0bdcb7e96d51c5d96b54b45c90648a7c6 (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
29
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 {
    // TODO USE SH-REPO
    private val patterns = mapOf(
        "health" to "§[c6](?<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)
            }
        }
    }
}