From d1c650497307c8f8ae09d2fc9bd2dc6070019208 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 May 2026 03:02:00 +0900 Subject: [PATCH] =?UTF-8?q?v1.3.2=20=E2=80=94=20verbose=20logging=20to=20d?= =?UTF-8?q?iagnose=20missing=20active=3D1b=20write?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 증상: chat_answer:status active 가 0b 그대로 → 데이터팩 login 메시지 안 뜸. mq:load 는 정상 작동(0b 초기화 됨)인데 모드의 onPlayerJoin 이 1b 로 안 씀. 추가 로그: - ChatAnswerFabric.onInitialize: 진입/완료, event register 예외시 ERROR - ChatAnswerCore.onPlayerJoin: 진입 (player 이름 포함), 성공 시 INFO, 실패 catch 를 LOG.debug → LOG.warn 으로 승격해 latest.log 에 보이게. 이 로그를 보고 다음 중 어디서 깨지는지 좁힐 수 있음: - "Fabric entrypoint onInitialize starting" 안 보임 → nested jar 미로드 - "onInitialize starting" 보이고 "registered" 안 보임 → fabric-api ABI mismatch - "onPlayerJoin fired" 안 보임 → JOIN 이벤트 미발화 - "active=1b set" 안 보이고 "failed" 만 보임 → command 실행 실패 Co-Authored-By: Claude Opus 4.7 --- .../chatanswer/core/ChatAnswerCore.java | 10 ++++++-- .../chatanswer/fabric/ChatAnswerFabric.java | 23 ++++++++++++++----- .../chatanswer/fabric/ChatAnswerFabric.java | 23 ++++++++++++++----- gradle.properties | 2 +- 4 files changed, 43 insertions(+), 15 deletions(-) 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=채팅정답