blob: b10c58a831ee748a50a6b8aabfa952e3b9737be0 (
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.ambientaddons.utils.dungeon
import com.ambientaddons.utils.Extensions.stripControlCodes
import com.ambientaddons.utils.Area
import com.ambientaddons.utils.SBLocation
import com.ambientaddons.utils.TabListUtils
import com.ambientaddons.utils.text
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
object DungeonPlayers {
private val playerRegex = Regex("^\\[\\d{1,3}] (?<name>[\\w]{3,16}) (?:.*)*\\((?:(?<class>Healer|Tank|Berserk|Mage|Archer) (?<level>[XVIL0]+)|(?<status>DEAD|EMPTY))\\)")
var playerCount = 0
private val playerSlots = listOf(5, 9, 13, 17, 1)
private var ticks = 0
@SubscribeEvent
fun onTick(event: ClientTickEvent) {
if (SBLocation.area != Area.Dungeon) return
if (ticks % 10 == 0) {
val rawPlayers = TabListUtils.fetchTabEntries().let { tabEntries ->
playerSlots.map { tabEntries[it].text.stripControlCodes() }
}
playerCount = rawPlayers.filter { it.isNotBlank() }.size
}
ticks++
}
}
|