aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/garden
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt23
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt33
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt30
3 files changed, 45 insertions, 41 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
index 54dfb6d62..403ff89d8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
@@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.TimeUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -22,8 +23,7 @@ import kotlin.time.Duration.Companion.seconds
class GardenVisitorTimer {
private val config get() = SkyHanniMod.feature.garden.visitors.timer
- private val patternNextVisitor = " Next Visitor: §r§b(?<time>.*)".toPattern()
- private val patternVisitors = "§b§lVisitors: §r§f\\((?<amount>\\d)\\)".toPattern()
+ private val pattern = "§b§lVisitors: §r§f\\((?<time>.*)\\)".toPattern()
private var render = ""
private var lastMillis = 0L
private var sixthVisitorArrivalTime: Long = 0
@@ -75,24 +75,23 @@ class GardenVisitorTimer {
private fun updateVisitorDisplay() {
if (!isEnabled()) return
- var visitorsAmount = 0
+ var visitorsAmount = VisitorAPI.visitorsInTabList(TabListData.getTabList()).size
var visitorInterval = visitorInterval ?: return
var millis = visitorInterval
var queueFull = false
for (line in TabListData.getTabList()) {
- val matcher = patternNextVisitor.matcher(line)
- if (matcher.matches()) {
- val rawTime = matcher.group("time")
- millis = TimeUtils.getMillis(rawTime)
- } else if (line == " Next Visitor: §r§c§lQueue Full!") {
+ if (line == "§b§lVisitors: §r§f(§r§c§lQueue Full!§r§f)") {
queueFull = true
- } else if (line == " Next Visitor: §r§cNot Unlocked!") {
+ continue
+ }
+ if (line == "§b§lVisitors: §r§cNot Unlocked!") {
render = ""
return
}
- patternVisitors.matchMatcher(line) {
- visitorsAmount = group("amount").toInt()
+ pattern.matchMatcher(line) {
+ val rawTime = group("time").removeColor()
+ millis = TimeUtils.getMillis(rawTime)
}
}
@@ -135,7 +134,7 @@ class GardenVisitorTimer {
val factor = diff / 1000.0
"§7/§$formatColor" + TimeUtils.formatDuration((millis / factor).roundToLong())
} else ""
- if (config.newVisitorPing && millis < 10000){
+ if (config.newVisitorPing && millis < 10000) {
SoundUtils.playBeepSound()
}
val formatDuration = TimeUtils.formatDuration(millis)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt
index 66b0ce39c..1c51e00a9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt
@@ -138,4 +138,37 @@ object VisitorAPI {
ACCEPTED("§7Accepted", LorenzColor.DARK_GRAY.toColor().withAlpha(80)),
REFUSED("§cRefused", LorenzColor.RED.toColor().withAlpha(60)),
}
+
+ fun visitorsInTabList(tabList: List<String>): MutableList<String> {
+ var found = false
+ val visitorsInTab = mutableListOf<String>()
+ for (line in tabList) {
+ if (line.startsWith("§b§lVisitors:")) {
+ found = true
+ continue
+ }
+ if (!found) continue
+
+ if (line.isEmpty() || line.contains("Account Info")) {
+ found = false
+ continue
+ }
+ val name = VisitorAPI.fromHypixelName(line)
+
+ // Hide hypixel watchdog entries
+ if (name.contains("§c") && !name.contains("Spaceman") && !name.contains("Grandma Wolf")) {
+ logger.log("Ignore wrong red name: '$name'")
+ continue
+ }
+
+ //hide own player name
+ if (name.contains(LorenzUtils.getPlayerName())) {
+ logger.log("Ignore wrong own name: '$name'")
+ continue
+ }
+
+ visitorsInTab.add(name)
+ }
+ return visitorsInTab
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt
index a1e7473a7..c2ed7d51b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt
@@ -66,35 +66,7 @@ class VisitorListener {
@SubscribeEvent
fun onTabListUpdate(event: TabListUpdateEvent) {
if (!GardenAPI.inGarden()) return
- var found = false
- val visitorsInTab = mutableListOf<String>()
- for (line in event.tabList) {
- if (line.startsWith("§b§lVisitors:")) {
- found = true
- continue
- }
- if (!found) continue
-
- if (line.isEmpty() || line.contains("Account Info")) {
- found = false
- continue
- }
- val name = VisitorAPI.fromHypixelName(line)
-
- // Hide hypixel watchdog entries
- if (name.contains("§c") && !name.contains("Spaceman") && !name.contains("Grandma Wolf")) {
- logger.log("Ignore wrong red name: '$name'")
- continue
- }
-
- //hide own player name
- if (name.contains(LorenzUtils.getPlayerName())) {
- logger.log("Ignore wrong own name: '$name'")
- continue
- }
-
- visitorsInTab.add(name)
- }
+ val visitorsInTab = VisitorAPI.visitorsInTabList(event.tabList)
VisitorAPI.getVisitors().forEach {
val name = it.visitorName