diff options
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/util')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt b/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt new file mode 100644 index 0000000..a0999f6 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt @@ -0,0 +1,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 "" + } +}
\ No newline at end of file |