fix: loading client-only classes on dedicated server

This commit is contained in:
xtex 2023-07-27 11:01:30 +08:00
parent 5beb4d977f
commit 849a88bbf6
Signed by: xtex
GPG Key ID: B918086ED8045B91

View File

@ -5,10 +5,14 @@ import com.google.gson.GsonBuilder
import dev.architectury.event.events.client.ClientPlayerEvent import dev.architectury.event.events.client.ClientPlayerEvent
import dev.architectury.platform.Platform import dev.architectury.platform.Platform
import dev.architectury.utils.GameInstance import dev.architectury.utils.GameInstance
import net.fabricmc.api.EnvType
import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.CompoundTag
import quaedam.Quaedam import quaedam.Quaedam
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.* import kotlin.io.path.exists
import kotlin.io.path.notExists
import kotlin.io.path.readText
import kotlin.io.path.writeText
data class QuaedamConfig( data class QuaedamConfig(
val projectorEffectRadius: Int = 4 val projectorEffectRadius: Int = 4
@ -31,9 +35,11 @@ data class QuaedamConfig(
init { init {
SimpleQuaedamConfigPush SimpleQuaedamConfigPush
ClientPlayerEvent.CLIENT_PLAYER_QUIT.register { player -> if (Platform.getEnv() == EnvType.CLIENT) {
if (player == GameInstance.getClient().player) { ClientPlayerEvent.CLIENT_PLAYER_QUIT.register { player ->
applyRemoteConfig(null) if (player == GameInstance.getClient().player) {
applyRemoteConfig(null)
}
} }
} }
if (localFile.notExists()) { if (localFile.notExists()) {