blob: 5130e7080163180f47bc4d7ce55b32308190284c (
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
30
31
32
33
34
35
|
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.LorenzActionBarEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Pattern
class ActionBarStatsData {
private val pattern =
Pattern.compile("..((?:\\d|,)*)\\/(?:\\d|,)*(.) *..((?:\\d|,)*)..(. \\w*) *..((?:\\d|,)*)\\/(?:\\d|,)*(.*)")
// Sample input: §c2,817/2,817❤ §a703§a❈ Defense §b3,479/3,479✎ Mana
// Returns the following groups: 1 = 2,817; 2 = ❤; 3 = 703; 4 = ❈ Defense; 5 = 3,479; 6 = ✎ Mana
companion object {
var groups = listOf<String>()
}
@SubscribeEvent
fun onActionBar(event: LorenzActionBarEvent) {
groups = readGroups(event.message)
}
private fun readGroups(message: String): List<String> {
if (!LorenzUtils.inSkyBlock) return emptyList()
val matcher = pattern.matcher(message)
if (!matcher.matches()) return emptyList()
val list = mutableListOf<String>()
for (i in 1..matcher.groupCount()) {
list.add(matcher.group(i))
}
return list
}
}
|