Add per compat project event listeners

[no changelog]
This commit is contained in:
Linnea Gräf
2024-09-01 22:21:19 +02:00
parent 816f80f862
commit 5ed74f2df4
20 changed files with 161 additions and 73 deletions

View File

@@ -26,7 +26,7 @@ object SBData {
val isOnSkyblock get() = locraw?.gametype == "SKYBLOCK"
var lastProfileIdRequest = TimeMark.farPast()
fun init() {
ServerConnectedEvent.subscribe {
ServerConnectedEvent.subscribe("SBData:onServerConnected") {
HypixelModAPI.getInstance().subscribeToEventPacket(ClientboundLocationPacket::class.java)
}
HypixelModAPI.getInstance().createHandler(ClientboundLocationPacket::class.java) {
@@ -39,18 +39,18 @@ object SBData {
SkyblockServerUpdateEvent.publish(SkyblockServerUpdateEvent(lastLocraw, null))
}
}
SkyblockServerUpdateEvent.subscribe {
SkyblockServerUpdateEvent.subscribe("SBData:sendProfileId") {
if (!hasReceivedProfile && isOnSkyblock && lastProfileIdRequest.passedTime() > 30.seconds) {
lastProfileIdRequest = TimeMark.now()
MC.sendServerCommand("profileid")
}
}
AllowChatEvent.subscribe { event ->
AllowChatEvent.subscribe("SBData:hideProfileSuggest") { event ->
if (event.unformattedString in profileSuggestTexts && lastProfileIdRequest.passedTime() < 5.seconds) {
event.cancel()
}
}
ProcessChatEvent.subscribe(receivesCancelled = true) { event ->
ProcessChatEvent.subscribe(receivesCancelled = true, "SBData:loadProfile") { event ->
val profileMatch = profileRegex.matchEntire(event.unformattedString)
if (profileMatch != null) {
try {