chore: replaced println() with proper logging util

Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
moonleay 2024-05-04 02:48:56 +02:00
parent 7cf65cffd2
commit 13cbbfa72f
Signed by: moonleay
GPG key ID: 82667543CCD715FB
2 changed files with 11 additions and 2 deletions

View file

@ -20,6 +20,7 @@ package net.moonleay.gimbal.client.editor
import net.minecraft.client.MinecraftClient import net.minecraft.client.MinecraftClient
import net.minecraft.text.Text import net.minecraft.text.Text
import net.moonleay.gimbal.build.BuildConstants
import net.moonleay.gimbal.client.util.ChatUtil import net.moonleay.gimbal.client.util.ChatUtil
import net.moonleay.gimbal.editor.ServerEditorManager import net.moonleay.gimbal.editor.ServerEditorManager
import net.moonleay.gimbal.editor.state.EditorState import net.moonleay.gimbal.editor.state.EditorState
@ -30,6 +31,7 @@ import net.moonleay.gimbal.editor.state.mode.Mode
import net.moonleay.gimbal.editor.state.mode.ModeModifier import net.moonleay.gimbal.editor.state.mode.ModeModifier
import net.moonleay.gimbal.editor.util.EditorUtil import net.moonleay.gimbal.editor.util.EditorUtil
import net.moonleay.gimbal.networking.GimbalClient import net.moonleay.gimbal.networking.GimbalClient
import org.apache.logging.log4j.LogManager
object ClientEditor { object ClientEditor {
private var POLICY = GimbalPolicyType.NOT_PRESENT private var POLICY = GimbalPolicyType.NOT_PRESENT
@ -43,6 +45,9 @@ object ClientEditor {
private val DISABLED_MODIFIERS_STORAGE = mutableListOf<ModeModifier>() private val DISABLED_MODIFIERS_STORAGE = mutableListOf<ModeModifier>()
private val LOGGER = LogManager.getLogger(BuildConstants.modName)
fun onConnectedToNewWorld() { fun onConnectedToNewWorld() {
POLICY = GimbalPolicyType.NOT_PRESENT POLICY = GimbalPolicyType.NOT_PRESENT
if (TEMP_DISABLED_MODE == Mode.UNKNOWN) { if (TEMP_DISABLED_MODE == Mode.UNKNOWN) {
@ -73,7 +78,7 @@ object ClientEditor {
if (!shouldUpdateServer) { if (!shouldUpdateServer) {
val player = MinecraftClient.getInstance().player val player = MinecraftClient.getInstance().player
if (player == null) { if (player == null) {
println("Player is null!") LOGGER.warn("Player is null!") //FIXME: Fix player is null at world join!
return return
} }
ServerEditorManager.updateEditorState( ServerEditorManager.updateEditorState(

View file

@ -18,6 +18,7 @@
package net.moonleay.gimbal.networking package net.moonleay.gimbal.networking
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.cbor.Cbor import kotlinx.serialization.cbor.Cbor
import kotlinx.serialization.decodeFromByteArray import kotlinx.serialization.decodeFromByteArray
import kotlinx.serialization.encodeToByteArray import kotlinx.serialization.encodeToByteArray
@ -33,8 +34,10 @@ import net.moonleay.gimbal.editor.ServerEditorManager
import net.moonleay.gimbal.editor.state.EditorState import net.moonleay.gimbal.editor.state.EditorState
import net.moonleay.gimbal.editor.state.GimbalPolicyType import net.moonleay.gimbal.editor.state.GimbalPolicyType
import net.moonleay.gimbal.editor.state.GimbalServerState import net.moonleay.gimbal.editor.state.GimbalServerState
import org.apache.logging.log4j.LogManager
object GimbalServer { object GimbalServer {
private val LOGGER = LogManager.getLogger(BuildConstants.modName)
fun registerPacketHandler() { fun registerPacketHandler() {
ServerPlayNetworking ServerPlayNetworking
@ -44,8 +47,9 @@ object GimbalServer {
} }
} }
@OptIn(ExperimentalSerializationApi::class)
fun notifyPlayerOfPolicy(player: ServerPlayerEntity) { fun notifyPlayerOfPolicy(player: ServerPlayerEntity) {
println("Sending policy packet to player ${player.name.string}...") LOGGER.info("Sending policy to " + player.name.string)
val buf = PacketByteBufs.create() val buf = PacketByteBufs.create()
buf.writeByteArray( buf.writeByteArray(
Cbor.encodeToByteArray( Cbor.encodeToByteArray(