aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/util')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/util/LegacyTagParser.kt17
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/util/SBData.kt28
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/util/config/ProfileSpecificConfigHolder.kt1
3 files changed, 37 insertions, 9 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/util/LegacyTagParser.kt b/src/main/kotlin/moe/nea/notenoughupdates/util/LegacyTagParser.kt
index 99409e0..9f3379b 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/util/LegacyTagParser.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/util/LegacyTagParser.kt
@@ -1,7 +1,17 @@
package moe.nea.notenoughupdates.util
-import net.minecraft.nbt.*
import java.util.*
+import net.minecraft.nbt.AbstractNbtNumber
+import net.minecraft.nbt.NbtByte
+import net.minecraft.nbt.NbtCompound
+import net.minecraft.nbt.NbtDouble
+import net.minecraft.nbt.NbtElement
+import net.minecraft.nbt.NbtFloat
+import net.minecraft.nbt.NbtInt
+import net.minecraft.nbt.NbtList
+import net.minecraft.nbt.NbtLong
+import net.minecraft.nbt.NbtShort
+import net.minecraft.nbt.NbtString
class LegacyTagParser private constructor(string: String) {
data class TagParsingException(val baseString: String, val offset: Int, val mes0: String) :
@@ -80,7 +90,7 @@ class LegacyTagParser private constructor(string: String) {
val baseTag = parseTag()
companion object {
- val digitRange = '0'..'9'
+ val digitRange = "0123456789-"
fun parse(string: String): NbtCompound {
return LegacyTagParser(string).baseTag
}
@@ -161,6 +171,7 @@ class LegacyTagParser private constructor(string: String) {
}
sb.append(escaped)
}
+
null -> racer.error("Unfinished string")
else -> {
sb.append(peek)
@@ -182,7 +193,7 @@ class LegacyTagParser private constructor(string: String) {
val SHORT = "([-+]?[0-9]+)[s|S]".toRegex()
val INTEGER = "([-+]?[0-9]+)".toRegex()
val DOUBLE_UNTYPED = "([-+]?[0-9]*\\.?[0-9]+)".toRegex()
- val ROUGH_PATTERN = "[-+]?[0-9]*\\.?[0-9]+[dDbBfFlLsS]?".toRegex()
+ val ROUGH_PATTERN = "[-+]?[0-9]*\\.?[0-9]*[dDbBfFlLsS]?".toRegex()
}
fun parseNumericTag(): AbstractNbtNumber {
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/util/SBData.kt b/src/main/kotlin/moe/nea/notenoughupdates/util/SBData.kt
index 5391206..4c31b56 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/util/SBData.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/util/SBData.kt
@@ -1,15 +1,18 @@
package moe.nea.notenoughupdates.util
-import dev.architectury.event.events.client.ClientPlayerEvent
+import java.time.Instant
import kotlinx.serialization.SerializationException
import kotlinx.serialization.decodeFromString
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
import kotlin.time.ExperimentalTime
import kotlin.time.TimeSource
+import net.minecraft.network.message.ArgumentSignatureDataMap
+import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket
import moe.nea.notenoughupdates.NotEnoughUpdates
import moe.nea.notenoughupdates.events.ServerChatLineReceivedEvent
import moe.nea.notenoughupdates.events.SkyblockServerUpdateEvent
+import moe.nea.notenoughupdates.events.WorldReadyEvent
@OptIn(ExperimentalTime::class)
object SBData {
@@ -32,15 +35,15 @@ object SBData {
val lLS = lastLocrawSent
if (tryReceiveLocraw(event.unformattedString) && lLS != null && lLS.elapsedNow() < locrawRoundtripTime) {
lastLocrawSent = null
- event.cancel()
+ // event.cancel()
}
}
}
- ClientPlayerEvent.CLIENT_PLAYER_JOIN.register(ClientPlayerEvent.ClientPlayerJoin {
- locraw = null
+ WorldReadyEvent.subscribe {
sendLocraw()
- })
+ locraw = null
+ }
}
private fun tryReceiveLocraw(unformattedString: String): Boolean = try {
@@ -49,14 +52,27 @@ object SBData {
SkyblockServerUpdateEvent.publish(SkyblockServerUpdateEvent(lastLocraw, locraw))
true
} catch (e: SerializationException) {
+ e.printStackTrace()
false
} catch (e: IllegalArgumentException) {
+ e.printStackTrace()
false
}
fun sendLocraw() {
lastLocrawSent = TimeSource.Monotonic.markNow()
- MC.player?.sendCommand("locraw")
+ val nh = MC.player?.networkHandler ?: return
+ val ack = nh.consumeAcknowledgment()
+ nh.sendPacket(
+ CommandExecutionC2SPacket(
+ "locraw",
+ Instant.now(),
+ 0L,
+ ArgumentSignatureDataMap.EMPTY,
+ false,
+ ack
+ )
+ )
}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/util/config/ProfileSpecificConfigHolder.kt b/src/main/kotlin/moe/nea/notenoughupdates/util/config/ProfileSpecificConfigHolder.kt
index 44a79c4..6a39e0a 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/util/config/ProfileSpecificConfigHolder.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/util/config/ProfileSpecificConfigHolder.kt
@@ -29,6 +29,7 @@ abstract class ProfileSpecificConfigHolder<S>(
init {
allConfigs = readValues()
readValues()
+ IConfigHolder.putConfig(this::class, this)
}
private val configDirectory: Path get() = NotEnoughUpdates.CONFIG_DIR.resolve("profiles")