From 13cbbfa72fe47a51cac9aa7aea43e76e153e2700 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 4 May 2024 02:48:56 +0200 Subject: [PATCH] chore: replaced println() with proper logging util Signed-off-by: moonleay --- .../java/net/moonleay/gimbal/client/editor/ClientEditor.kt | 7 ++++++- .../java/net/moonleay/gimbal/networking/GimbalServer.kt | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/moonleay/gimbal/client/editor/ClientEditor.kt b/src/main/java/net/moonleay/gimbal/client/editor/ClientEditor.kt index a220346..dde4c56 100644 --- a/src/main/java/net/moonleay/gimbal/client/editor/ClientEditor.kt +++ b/src/main/java/net/moonleay/gimbal/client/editor/ClientEditor.kt @@ -20,6 +20,7 @@ package net.moonleay.gimbal.client.editor import net.minecraft.client.MinecraftClient import net.minecraft.text.Text +import net.moonleay.gimbal.build.BuildConstants import net.moonleay.gimbal.client.util.ChatUtil import net.moonleay.gimbal.editor.ServerEditorManager 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.util.EditorUtil import net.moonleay.gimbal.networking.GimbalClient +import org.apache.logging.log4j.LogManager object ClientEditor { private var POLICY = GimbalPolicyType.NOT_PRESENT @@ -43,6 +45,9 @@ object ClientEditor { private val DISABLED_MODIFIERS_STORAGE = mutableListOf() + private val LOGGER = LogManager.getLogger(BuildConstants.modName) + + fun onConnectedToNewWorld() { POLICY = GimbalPolicyType.NOT_PRESENT if (TEMP_DISABLED_MODE == Mode.UNKNOWN) { @@ -73,7 +78,7 @@ object ClientEditor { if (!shouldUpdateServer) { val player = MinecraftClient.getInstance().player if (player == null) { - println("Player is null!") + LOGGER.warn("Player is null!") //FIXME: Fix player is null at world join! return } ServerEditorManager.updateEditorState( diff --git a/src/main/java/net/moonleay/gimbal/networking/GimbalServer.kt b/src/main/java/net/moonleay/gimbal/networking/GimbalServer.kt index 82f8968..fd0e654 100644 --- a/src/main/java/net/moonleay/gimbal/networking/GimbalServer.kt +++ b/src/main/java/net/moonleay/gimbal/networking/GimbalServer.kt @@ -18,6 +18,7 @@ package net.moonleay.gimbal.networking +import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.cbor.Cbor import kotlinx.serialization.decodeFromByteArray 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.GimbalPolicyType import net.moonleay.gimbal.editor.state.GimbalServerState +import org.apache.logging.log4j.LogManager object GimbalServer { + private val LOGGER = LogManager.getLogger(BuildConstants.modName) fun registerPacketHandler() { ServerPlayNetworking @@ -44,8 +47,9 @@ object GimbalServer { } } + @OptIn(ExperimentalSerializationApi::class) 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() buf.writeByteArray( Cbor.encodeToByteArray(