Send profile id even more rarely

This commit is contained in:
Linnea Gräf
2024-09-06 20:18:28 +02:00
parent 2d936ea4a2
commit 4c4c639434

View File

@@ -24,7 +24,7 @@ object SBData {
val skyblockLocation: SkyBlockIsland? get() = locraw?.skyblockLocation val skyblockLocation: SkyBlockIsland? get() = locraw?.skyblockLocation
val hasValidLocraw get() = locraw?.server !in listOf("limbo", null) val hasValidLocraw get() = locraw?.server !in listOf("limbo", null)
val isOnSkyblock get() = locraw?.gametype == "SKYBLOCK" val isOnSkyblock get() = locraw?.gametype == "SKYBLOCK"
var lastProfileIdRequest = TimeMark.farPast() var profileIdCommandDebounce = TimeMark.farPast()
fun init() { fun init() {
ServerConnectedEvent.subscribe("SBData:onServerConnected") { ServerConnectedEvent.subscribe("SBData:onServerConnected") {
HypixelModAPI.getInstance().subscribeToEventPacket(ClientboundLocationPacket::class.java) HypixelModAPI.getInstance().subscribeToEventPacket(ClientboundLocationPacket::class.java)
@@ -37,16 +37,17 @@ object SBData {
it.mode.getOrNull(), it.mode.getOrNull(),
it.map.getOrNull()) it.map.getOrNull())
SkyblockServerUpdateEvent.publish(SkyblockServerUpdateEvent(lastLocraw, null)) SkyblockServerUpdateEvent.publish(SkyblockServerUpdateEvent(lastLocraw, null))
profileIdCommandDebounce = TimeMark.now()
} }
} }
SkyblockServerUpdateEvent.subscribe("SBData:sendProfileId") { SkyblockServerUpdateEvent.subscribe("SBData:sendProfileId") {
if (!hasReceivedProfile && isOnSkyblock && lastProfileIdRequest.passedTime() > 30.seconds) { if (!hasReceivedProfile && isOnSkyblock && profileIdCommandDebounce.passedTime() > 10.seconds) {
lastProfileIdRequest = TimeMark.now() profileIdCommandDebounce = TimeMark.now()
MC.sendServerCommand("profileid") MC.sendServerCommand("profileid")
} }
} }
AllowChatEvent.subscribe("SBData:hideProfileSuggest") { event -> AllowChatEvent.subscribe("SBData:hideProfileSuggest") { event ->
if (event.unformattedString in profileSuggestTexts && lastProfileIdRequest.passedTime() < 5.seconds) { if (event.unformattedString in profileSuggestTexts && profileIdCommandDebounce.passedTime() < 5.seconds) {
event.cancel() event.cancel()
} }
} }