diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-07-30 10:28:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-30 10:28:05 +0200 |
commit | a3c940937bccd9f92acdc3ad2abe8e39e71ca847 (patch) | |
tree | b96f7255c1e30bb7fd11cd512944760d42470dc6 /src/main/java/at/hannibal2/skyhanni | |
parent | db5ec7f5046ea6f531a2f560b198cd8c24b36ec5 (diff) | |
download | skyhanni-a3c940937bccd9f92acdc3ad2abe8e39e71ca847.tar.gz skyhanni-a3c940937bccd9f92acdc3ad2abe8e39e71ca847.tar.bz2 skyhanni-a3c940937bccd9f92acdc3ad2abe8e39e71ca847.zip |
Improvement: Fewer Tab list chat errors (#2266)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
3 files changed, 38 insertions, 18 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java index 171cb82b1..c3b949c79 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java @@ -23,6 +23,9 @@ public class PlayerSpecificStorage { public Boolean useRomanNumerals = true; @Expose + public Boolean multipleProfiles = false; + + @Expose public Integer gardenCommunityUpgrade = -1; @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index dbcf12760..bc43a807e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -293,6 +293,7 @@ object HypixelData { if (profileName == newProfile) return profileName = newProfile ProfileJoinEvent(newProfile).postAndCatch() + ProfileStorageData.profileJoinMessage() } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt index 18211ccd8..ad119804b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt @@ -8,6 +8,7 @@ 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.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.WidgetUpdateEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -32,6 +33,7 @@ object ProfileStorageData { private var sackPlayers: SackData.PlayerSpecific? = null var sackProfiles: SackData.ProfileSpecific? = null + var hypixelDataLoaded = false @SubscribeEvent(priority = EventPriority.HIGHEST) fun onProfileJoin(event: ProfileJoinEvent) { @@ -84,24 +86,28 @@ object ProfileStorageData { if (!LorenzUtils.inSkyBlock) return if (noTabListTime == SimpleTimeMark.farPast()) return - if (noTabListTime.passedSince() > 3.seconds) { - noTabListTime = SimpleTimeMark.now() - val foundSkyBlockTabList = TabListData.getTabList().any { it.contains("§b§lArea:") } - if (foundSkyBlockTabList) { - ChatUtils.clickableChat( - "§cCan not read profile name from tab list! Open /widget and enable Profile Widget. " + - "This is needed for the mod to function! And therefore this warning cannot be disabled", - onClick = { - HypixelCommands.widget() - }, - "§eClick to run /widget!", - ) - } else { - ChatUtils.chat( - "§cExtra Information from Tab list not found! " + - "Enable it: SkyBlock Menu ➜ Settings ➜ Personal ➜ User Interface ➜ Player List Info", - ) - } + playerSpecific?.let { + // do not try to load the data when hypixel has not yet send the profile loaded message + if (it.multipleProfiles && !hypixelDataLoaded) return + } + + if (noTabListTime.passedSince() < 5.seconds) return + noTabListTime = SimpleTimeMark.now() + val foundSkyBlockTabList = TabListData.getTabList().any { it.contains("§b§lArea:") } + if (foundSkyBlockTabList) { + ChatUtils.clickableChat( + "§cCan not read profile name from tab list! Open /widget and enable Profile Widget. " + + "This is needed for the mod to function! And therefore this warning cannot be disabled", + onClick = { + HypixelCommands.widget() + }, + "§eClick to run /widget!", + ) + } else { + ChatUtils.chat( + "§cExtra Information from Tab list not found! " + + "Enable it: SkyBlock Menu ➜ Settings ➜ Personal ➜ User Interface ➜ Player List Info", + ) } } @@ -124,4 +130,14 @@ object ProfileStorageData { sackPlayers = SkyHanniMod.sackData.players.getOrPut(playerUuid) { SackData.PlayerSpecific() } ConfigLoadEvent().postAndCatch() } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + hypixelDataLoaded = false + } + + fun profileJoinMessage() { + hypixelDataLoaded = true + playerSpecific?.multipleProfiles = true + } } |