blob: a0999f66c754a9342d51a24640da2b6824129510 (
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 com.dulkirfabric.util
import com.dulkirfabric.DulkirModFabric.mc
import com.dulkirfabric.events.LongUpdateEvent
import meteordevelopment.orbit.EventHandler
import net.minecraft.client.network.PlayerListEntry
object TablistUtils {
var tablist: List<PlayerListEntry>? = null
private val areaPattern = "Area: (.+)".toRegex()
var area: String = ""
@EventHandler
fun onLongUpdate(event: LongUpdateEvent) {
if (mc.player == null) return
tablist = mc.inGameHud.playerListHud.collectPlayerEntries()
area = updateArea()
}
private fun updateArea(): String {
if (tablist == null) return ""
tablist!!.forEach {
val match = areaPattern.find(it.displayName?.string ?: return@forEach) ?: return@forEach
return match.groupValues[1]
}
return ""
}
}
|