Skip to content

Commit 24e3945

Browse files
committed
Hotfix: ReFixed VisitorUtils.kt
1 parent 4271c1c commit 24e3945

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/main/kotlin/io/github/frostzie/skyfall/utils/garden/VisitorUtils.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ data class VisitorData(
2222
* at the Garden's main desk.
2323
*/
2424
object VisitorUtils {
25-
25+
private val VISITOR_PATTERN = "Visitors: \\((.*)\\)".toRegex()
2626
private var cachedVisitorData: VisitorData = VisitorData.NONE
2727
private var onGarden: Boolean = false
2828

@@ -48,23 +48,20 @@ object VisitorUtils {
4848
private fun recalculateVisitorData(tabLines: List<String>) {
4949
var visitorCount: Int? = null
5050
val cleanLines = tabLines.map { ColorUtils.stripColorCodes(it) }
51+
5152
for (line in cleanLines) {
52-
val match = "§b§lVisitors: §r§f\\((.*)\\)".toRegex().find(line)
53+
val match = VISITOR_PATTERN.find(line)
5354
if (match != null) {
5455
val countInfo = match.groupValues[1]
5556
visitorCount = when {
5657
countInfo.contains("Queue Full") -> 5
5758
countInfo.toIntOrNull() != null -> countInfo.toInt()
5859
else -> null
5960
}
60-
if (visitorCount != null) break
61+
break
6162
}
6263
}
6364

64-
if (visitorCount != null) {
65-
if (cachedVisitorData.count != visitorCount) {
66-
cachedVisitorData = VisitorData(visitorCount)
67-
}
68-
}
65+
cachedVisitorData = if (visitorCount != null) VisitorData(visitorCount) else VisitorData.NONE
6966
}
7067
}

0 commit comments

Comments
 (0)