Skip to content

Commit

Permalink
Improvement: Fewer Tab list chat errors (#2266)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
hannibal002 and hannibal002 authored Jul 30, 2024
1 parent db5ec7f commit a3c9409
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class PlayerSpecificStorage {
@Expose
public Boolean useRomanNumerals = true;

@Expose
public Boolean multipleProfiles = false;

@Expose
public Integer gardenCommunityUpgrade = -1;

Expand Down
1 change: 1 addition & 0 deletions src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ object HypixelData {
if (profileName == newProfile) return
profileName = newProfile
ProfileJoinEvent(newProfile).postAndCatch()
ProfileStorageData.profileJoinMessage()
}
}

Expand Down
52 changes: 34 additions & 18 deletions src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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",
)
}
}

Expand All @@ -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
}
}

0 comments on commit a3c9409

Please sign in to comment.