diff options
author | ronald <inglettronald@gmail.com> | 2023-07-29 22:35:40 -0500 |
---|---|---|
committer | ronald <inglettronald@gmail.com> | 2023-07-29 22:35:40 -0500 |
commit | 655a52aca8e7d7ebea63f3fcd30d1d6e8b916f61 (patch) | |
tree | e93744e961fd9bc78a3b8913ff40f399c1c14499 /src/main/kotlin/com/dulkirfabric/util | |
parent | 4fdc7858ce3a480f983c3a12ff0a0627533e3c93 (diff) | |
download | DulkirMod-Fabric-655a52aca8e7d7ebea63f3fcd30d1d6e8b916f61.tar.gz DulkirMod-Fabric-655a52aca8e7d7ebea63f3fcd30d1d6e8b916f61.tar.bz2 DulkirMod-Fabric-655a52aca8e7d7ebea63f3fcd30d1d6e8b916f61.zip |
added some garden stuff
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/util')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt b/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt index 821c1c5..881b3b9 100644 --- a/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt +++ b/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt @@ -9,9 +9,16 @@ object TablistUtils { var tablist: List<PlayerListEntry>? = null private val areaPattern = "Area: (.+)".toRegex() private val speedPattern = "^Speed: (.+)".toRegex() + private val visitorPattern = "Visitors: \\((.+)\\)".toRegex() + private val nextVisitorPattern = "Next Visitor: (.+)".toRegex() + private val compostTimePattern = "Time Left: (.+)".toRegex() + data class PersistentInfo( var area: String = "", - var speed: String = "" + var speed: String = "", + var numVisitors: Int = 0, + var nextVisitorTime: String = "", + var compostTime: String = "" ) var persistentInfo: PersistentInfo = PersistentInfo() @@ -26,17 +33,31 @@ object TablistUtils { private fun updatePersistentData() { if (tablist == null) return tablist!!.forEach { - areaPattern.find(it.displayName?.string ?: return@forEach) ?.let { result -> + val str = it.displayName?.string?.trim() ?: return@forEach + areaPattern.find(str)?.let { result -> persistentInfo.area = result.groupValues[1] return@forEach } - speedPattern.matchEntire(it.displayName?.string?.trim() ?: return@forEach) ?.let { result -> + speedPattern.matchEntire(str)?.let { result -> persistentInfo.speed = result.groupValues[1] return@forEach } - } + visitorPattern.matchEntire(str)?.let { result -> + persistentInfo.numVisitors = result.groupValues[1].toInt() + return@forEach + } + + nextVisitorPattern.matchEntire(str)?.let { result -> + persistentInfo.nextVisitorTime = result.groupValues[1] + return@forEach + } + compostTimePattern.matchEntire(str)?.let { result -> + persistentInfo.compostTime = result.groupValues[1] + return@forEach + } + } } }
\ No newline at end of file |