diff --git a/common/src/main/java/kr/tkrmagid/chatanswer/core/ChatAnswerCore.java b/common/src/main/java/kr/tkrmagid/chatanswer/core/ChatAnswerCore.java index ba0d06d..611be67 100644 --- a/common/src/main/java/kr/tkrmagid/chatanswer/core/ChatAnswerCore.java +++ b/common/src/main/java/kr/tkrmagid/chatanswer/core/ChatAnswerCore.java @@ -38,16 +38,22 @@ public final class ChatAnswerCore { * 호출이 일어나지 않아 0b 로 유지되고, 모드가 있으면 첫 로그인 직후 1b 로 갱신. */ public static void onPlayerJoin(ServerPlayer player) { + String name = player.getName().getString(); + LOG.info("[{}] onPlayerJoin fired for {}", MOD_ID, name); MinecraftServer server = player.level().getServer(); - if (server == null) return; + if (server == null) { + LOG.warn("[{}] onPlayerJoin: server is null, skipping active-flag set for {}", MOD_ID, name); + return; + } CommandSourceStack source = server.createCommandSourceStack().withSuppressedOutput(); try { server.getCommands().performPrefixedCommand( source, "data modify storage chat_answer:status active set value 1b" ); + LOG.info("[{}] active=1b set after {} joined", MOD_ID, name); } catch (Exception e) { - LOG.debug("[{}] failed to set active flag: {}", MOD_ID, e.toString()); + LOG.warn("[{}] failed to set active flag for {}: {}", MOD_ID, name, e.toString(), e); } } diff --git a/fabric-1216/src/main/java/kr/tkrmagid/chatanswer/fabric/ChatAnswerFabric.java b/fabric-1216/src/main/java/kr/tkrmagid/chatanswer/fabric/ChatAnswerFabric.java index 587f5b4..ea8de97 100644 --- a/fabric-1216/src/main/java/kr/tkrmagid/chatanswer/fabric/ChatAnswerFabric.java +++ b/fabric-1216/src/main/java/kr/tkrmagid/chatanswer/fabric/ChatAnswerFabric.java @@ -4,15 +4,26 @@ import kr.tkrmagid.chatanswer.core.ChatAnswerCore; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.message.v1.ServerMessageEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class ChatAnswerFabric implements ModInitializer { + private static final Logger LOG = LoggerFactory.getLogger(ChatAnswerCore.MOD_ID); + @Override public void onInitialize() { - ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) -> - ChatAnswerCore.handleChat(sender, message.signedContent()) - ); - ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> - ChatAnswerCore.onPlayerJoin(handler.player) - ); + LOG.info("[{}] Fabric entrypoint onInitialize starting", ChatAnswerCore.MOD_ID); + try { + ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) -> + ChatAnswerCore.handleChat(sender, message.signedContent()) + ); + ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> + ChatAnswerCore.onPlayerJoin(handler.player) + ); + LOG.info("[{}] Fabric entrypoint registered: ALLOW_CHAT_MESSAGE + JOIN", ChatAnswerCore.MOD_ID); + } catch (Throwable t) { + LOG.error("[{}] Fabric entrypoint event registration failed", ChatAnswerCore.MOD_ID, t); + throw t; + } } } diff --git a/fabric-2612/src/main/java/kr/tkrmagid/chatanswer/fabric/ChatAnswerFabric.java b/fabric-2612/src/main/java/kr/tkrmagid/chatanswer/fabric/ChatAnswerFabric.java index 587f5b4..ea8de97 100644 --- a/fabric-2612/src/main/java/kr/tkrmagid/chatanswer/fabric/ChatAnswerFabric.java +++ b/fabric-2612/src/main/java/kr/tkrmagid/chatanswer/fabric/ChatAnswerFabric.java @@ -4,15 +4,26 @@ import kr.tkrmagid.chatanswer.core.ChatAnswerCore; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.message.v1.ServerMessageEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class ChatAnswerFabric implements ModInitializer { + private static final Logger LOG = LoggerFactory.getLogger(ChatAnswerCore.MOD_ID); + @Override public void onInitialize() { - ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) -> - ChatAnswerCore.handleChat(sender, message.signedContent()) - ); - ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> - ChatAnswerCore.onPlayerJoin(handler.player) - ); + LOG.info("[{}] Fabric entrypoint onInitialize starting", ChatAnswerCore.MOD_ID); + try { + ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) -> + ChatAnswerCore.handleChat(sender, message.signedContent()) + ); + ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> + ChatAnswerCore.onPlayerJoin(handler.player) + ); + LOG.info("[{}] Fabric entrypoint registered: ALLOW_CHAT_MESSAGE + JOIN", ChatAnswerCore.MOD_ID); + } catch (Throwable t) { + LOG.error("[{}] Fabric entrypoint event registration failed", ChatAnswerCore.MOD_ID, t); + throw t; + } } } diff --git a/gradle.properties b/gradle.properties index 884cef9..e92d083 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.parallel=true # ───── mod metadata ───────────────────────────────────────────────────────── mod_id=chat_answer -mod_version=1.3.1 +mod_version=1.3.2 mod_group=kr.tkrmagid.chatanswer mod_name=채팅정답