aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util/SBData.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-09-04 20:22:51 +0200
committernea <nea@nea.moe>2023-09-04 20:22:51 +0200
commitd202ef5439a180efecc27ab4695b1a12febb041f (patch)
tree959ac68db802d562dee2d92aecbb3741dbcce3b6 /src/main/kotlin/moe/nea/firmament/util/SBData.kt
parentee5591684dc6bcdea6c44a62806d537bbb7e0cee (diff)
downloadfirmament-d202ef5439a180efecc27ab4695b1a12febb041f.tar.gz
firmament-d202ef5439a180efecc27ab4695b1a12febb041f.tar.bz2
firmament-d202ef5439a180efecc27ab4695b1a12febb041f.zip
Make chat events use fabric events
[no changelog]
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util/SBData.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/SBData.kt24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/SBData.kt b/src/main/kotlin/moe/nea/firmament/util/SBData.kt
index 8af905e..fdec432 100644
--- a/src/main/kotlin/moe/nea/firmament/util/SBData.kt
+++ b/src/main/kotlin/moe/nea/firmament/util/SBData.kt
@@ -6,18 +6,17 @@
package moe.nea.firmament.util
-import java.util.*
import kotlinx.serialization.SerializationException
import kotlinx.serialization.decodeFromString
-import kotlin.time.Duration
-import kotlin.time.Duration.Companion.seconds
-import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket
import moe.nea.firmament.Firmament
-import moe.nea.firmament.events.ClientChatLineReceivedEvent
import moe.nea.firmament.events.OutgoingPacketEvent
-import moe.nea.firmament.events.ServerChatLineReceivedEvent
+import moe.nea.firmament.events.ProcessChatEvent
import moe.nea.firmament.events.SkyblockServerUpdateEvent
import moe.nea.firmament.events.WorldReadyEvent
+import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket
+import java.util.*
+import kotlin.time.Duration
+import kotlin.time.Duration.Companion.seconds
object SBData {
private val profileRegex = "Profile ID: ([a-z0-9\\-]+)".toRegex()
@@ -38,7 +37,7 @@ object SBData {
anyLocrawSent.markNow()
}
}
- ServerChatLineReceivedEvent.subscribe { event ->
+ ProcessChatEvent.subscribe(receivesCancelled = true) { event ->
val profileMatch = profileRegex.matchEntire(event.unformattedString)
if (profileMatch != null) {
try {
@@ -54,23 +53,22 @@ object SBData {
}
if (event.unformattedString.startsWith("{")) {
if (tryReceiveLocraw(event.unformattedString)) {
+ if (lastLocrawSent.timePassed() < locrawRoundtripTime) {
+ lastLocrawSent.markFarPast()
+ event.cancel()
+ }
if (!hasValidLocraw && !hasSentLocraw && hasReceivedProfile) {
sendLocraw()
}
}
}
}
- ClientChatLineReceivedEvent.subscribe { event ->
- if (event.unformattedString.startsWith("{") && tryReceiveLocraw(event.unformattedString) && lastLocrawSent.timePassed() < locrawRoundtripTime) {
- lastLocrawSent.markFarPast()
- event.cancel()
- }
- }
WorldReadyEvent.subscribe {
locraw = null
hasSentLocraw = false
hasReceivedProfile = false
+ profileId = null
}
}