aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-06-23 18:13:52 +0200
committerGitHub <noreply@github.com>2024-06-23 18:13:52 +0200
commitcc291932906c38943e20cee29ee591695a9875b5 (patch)
treeb7290d5ef35cd89fcd8f331ae4d70d0428301b0a /src/main/java/at/hannibal2/skyhanni/data
parent796bdf65f24057d170b91cc043a7fa8e024905ad (diff)
downloadskyhanni-cc291932906c38943e20cee29ee591695a9875b5.tar.gz
skyhanni-cc291932906c38943e20cee29ee591695a9875b5.tar.bz2
skyhanni-cc291932906c38943e20cee29ee591695a9875b5.zip
Backend: Usage of TabWidget (#1240)
Co-authored-by: Cal <cwolfson58@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt17
2 files changed, 13 insertions, 26 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
index 7599cc80f..82bd6d315 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
@@ -11,7 +11,6 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent
-import at.hannibal2.skyhanni.events.TabListUpdateEvent
import at.hannibal2.skyhanni.events.WidgetUpdateEvent
import at.hannibal2.skyhanni.events.minecraft.ClientDisconnectEvent
import at.hannibal2.skyhanni.features.bingo.BingoAPI
@@ -59,10 +58,6 @@ object HypixelData {
"serverid.scoreboard",
"§7\\d+/\\d+/\\d+ §8(?<servertype>[mM])(?<serverid>\\S+).*",
)
- private val serverIdTablistPattern by patternGroup.pattern(
- "serverid.tablist",
- " Server: §r§8(?<serverid>\\S+)",
- )
private val lobbyTypePattern by patternGroup.pattern(
"lobbytype",
"(?<lobbyType>.*lobby)\\d+",
@@ -161,14 +156,14 @@ object HypixelData {
if (LorenzUtils.lastWorldSwitch.passedSince() < 1.seconds) return
if (!TabListData.fullyLoaded) return
- ScoreboardData.sidebarLinesFormatted.matchFirst(serverIdScoreboardPattern) {
- val serverType = if (group("servertype") == "M") "mega" else "mini"
- serverId = "$serverType${group("serverid")}"
+ TabWidget.SERVER.matchMatcherFirstLine {
+ serverId = group("serverid")
return
}
- TabListData.getTabList().matchFirst(serverIdTablistPattern) {
- serverId = group("serverid")
+ ScoreboardData.sidebarLinesFormatted.matchFirst(serverIdScoreboardPattern) {
+ val serverType = if (group("servertype") == "M") "mega" else "mini"
+ serverId = "$serverType${group("serverid")}"
return
}
@@ -301,11 +296,9 @@ object HypixelData {
}
}
- @SubscribeEvent
- fun onTabListUpdate(event: TabListUpdateEvent) {
- event.tabList.matchFirst(UtilsPatterns.tabListProfilePattern) {
+ private fun checkProfile() {
+ TabWidget.PROFILE.matchMatcherFirstLine {
var newProfile = group("profile").lowercase()
-
// Hypixel shows the profile name reversed while in the Rift
if (RiftAPI.inRift()) newProfile = newProfile.reversed()
if (profileName == newProfile) return
@@ -374,6 +367,7 @@ object HypixelData {
fun onTabListUpdate(event: WidgetUpdateEvent) {
when (event.widget) {
TabWidget.AREA -> checkIsland(event)
+ TabWidget.PROFILE -> checkProfile()
else -> Unit
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
index 3d9bdcf78..18211ccd8 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
@@ -4,21 +4,20 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.SackData
import at.hannibal2.skyhanni.config.storage.PlayerSpecificStorage
import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage
+import at.hannibal2.skyhanni.data.model.TabWidget
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.HypixelJoinEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
-import at.hannibal2.skyhanni.events.TabListUpdateEvent
+import at.hannibal2.skyhanni.events.WidgetUpdateEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.TabListData
-import at.hannibal2.skyhanni.utils.UtilsPatterns
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
@@ -75,15 +74,9 @@ object ProfileStorageData {
}
@SubscribeEvent
- fun onTabListUpdate(event: TabListUpdateEvent) {
- if (!LorenzUtils.inSkyBlock) return
-
- event.tabList.matchFirst(UtilsPatterns.tabListProfilePattern) {
- noTabListTime = SimpleTimeMark.farPast()
- return
- }
-
- noTabListTime = SimpleTimeMark.now()
+ fun onTabListUpdate(event: WidgetUpdateEvent) {
+ if (!event.isWidget(TabWidget.PROFILE)) return
+ noTabListTime = if (event.isClear()) SimpleTimeMark.now() else SimpleTimeMark.farPast()
}
@SubscribeEvent