2 Commits

Author SHA1 Message Date
Claude
a67ec47f89 v1.3.3 — replace storage flag with direct function call (race-free)
이전 v1.3.2: onPlayerJoin 에서 storage chat_answer:status active=1b 를 set.
하지만 통합 서버 (integrated singleplayer) 에서 데이터팩의 mq:load 가
player join 이후에 도는 케이스가 있어 모드가 써놓은 1b 를 데이터팩이
0b 로 덮어쓰는 race 가 있었고, repeat/players 의 첫 tick 체크 시점에
이미 0b 라서 알림 메세지가 안 떴음.

v1.3.3: storage flag 자체를 폐기. onPlayerJoin 에서
  execute as <uuid> at @s run function mq:players/mod_active_notice
를 호출. 데이터팩이 메세지 텍스트를 정의하고, 모드는 "지금 들어온 이
플레이어에게 보여라" 만 트리거한다. 데이터팩 자체가 없으면 함수가 없어
suppressed source 의 command 실패로 silent → 안전.

데이터팩(music_quiz) 도 동일 커밋으로 함수 추가 및 flag 제거됨.
2026-05-14 03:15:04 +09:00
Claude
d1c6504973 v1.3.2 — verbose logging to diagnose missing active=1b write
증상: 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 <noreply@anthropic.com>
2026-05-14 03:02:00 +09:00
4 changed files with 56 additions and 23 deletions

View File

@@ -32,22 +32,33 @@ public final class ChatAnswerCore {
private ChatAnswerCore() {} private ChatAnswerCore() {}
/** /**
* 플레이어 로그인 직후 호출. 데이터팩이 "모드 살아있음" 신호로 쓸 수 있게 * 플레이어 로그인 직후 호출. 음악퀴즈 데이터팩의
* storage chat_answer:status 에 active=1b 를 세팅한다. 데이터팩의 mq:load 가 * mq:players/mod_active_notice
* 매 /reload 와 서버 시작 시 이 값을 0b 로 clear 하므로, 모드가 없으면 이 * 함수를 해당 플레이어 컨텍스트로 직접 호출한다. 데이터팩이 메세지를 정의하고,
* 호출이 일어나지 않아 0b 로 유지되고, 모드가 있으면 첫 로그인 직후 1b 로 갱신. * 모드는 "지금 막 들어온 이 플레이어에게 보여라" 만 트리거한다.
*
* 이전엔 storage chat_answer:status active=1b 플래그를 썼는데, 통합 서버에서
* mq:load 의 0b 초기화가 player join 이후에 도는 케이스 때문에 race 가 발생했다.
* 함수를 모드가 직접 호출하면 race 가 사라지고, 데이터팩이 없을 땐 함수가
* 존재하지 않아 커맨드가 (suppressed source 라 채팅엔 안 뜨고 log warn 으로)
* 무시된다.
*/ */
public static void onPlayerJoin(ServerPlayer player) { public static void onPlayerJoin(ServerPlayer player) {
String name = player.getName().getString();
LOG.info("[{}] onPlayerJoin fired for {}", MOD_ID, name);
MinecraftServer server = player.level().getServer(); MinecraftServer server = player.level().getServer();
if (server == null) return; if (server == null) {
LOG.warn("[{}] onPlayerJoin: server is null, skipping notice for {}", MOD_ID, name);
return;
}
CommandSourceStack source = server.createCommandSourceStack().withSuppressedOutput(); CommandSourceStack source = server.createCommandSourceStack().withSuppressedOutput();
String command = "execute as " + player.getStringUUID()
+ " at @s run function mq:players/mod_active_notice";
try { try {
server.getCommands().performPrefixedCommand( server.getCommands().performPrefixedCommand(source, command);
source, LOG.info("[{}] mod_active_notice invoked for {}", MOD_ID, name);
"data modify storage chat_answer:status active set value 1b"
);
} catch (Exception e) { } catch (Exception e) {
LOG.debug("[{}] failed to set active flag: {}", MOD_ID, e.toString()); LOG.warn("[{}] failed to invoke mod_active_notice for {}: {}", MOD_ID, name, e.toString(), e);
} }
} }

View File

@@ -4,15 +4,26 @@ import kr.tkrmagid.chatanswer.core.ChatAnswerCore;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.message.v1.ServerMessageEvents; import net.fabricmc.fabric.api.message.v1.ServerMessageEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class ChatAnswerFabric implements ModInitializer { public final class ChatAnswerFabric implements ModInitializer {
private static final Logger LOG = LoggerFactory.getLogger(ChatAnswerCore.MOD_ID);
@Override @Override
public void onInitialize() { public void onInitialize() {
ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) -> LOG.info("[{}] Fabric entrypoint onInitialize starting", ChatAnswerCore.MOD_ID);
ChatAnswerCore.handleChat(sender, message.signedContent()) try {
); ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) ->
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> ChatAnswerCore.handleChat(sender, message.signedContent())
ChatAnswerCore.onPlayerJoin(handler.player) );
); 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;
}
} }
} }

View File

@@ -4,15 +4,26 @@ import kr.tkrmagid.chatanswer.core.ChatAnswerCore;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.message.v1.ServerMessageEvents; import net.fabricmc.fabric.api.message.v1.ServerMessageEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class ChatAnswerFabric implements ModInitializer { public final class ChatAnswerFabric implements ModInitializer {
private static final Logger LOG = LoggerFactory.getLogger(ChatAnswerCore.MOD_ID);
@Override @Override
public void onInitialize() { public void onInitialize() {
ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) -> LOG.info("[{}] Fabric entrypoint onInitialize starting", ChatAnswerCore.MOD_ID);
ChatAnswerCore.handleChat(sender, message.signedContent()) try {
); ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) ->
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> ChatAnswerCore.handleChat(sender, message.signedContent())
ChatAnswerCore.onPlayerJoin(handler.player) );
); 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;
}
} }
} }

View File

@@ -3,7 +3,7 @@ org.gradle.parallel=true
# ───── mod metadata ───────────────────────────────────────────────────────── # ───── mod metadata ─────────────────────────────────────────────────────────
mod_id=chat_answer mod_id=chat_answer
mod_version=1.3.1 mod_version=1.3.3
mod_group=kr.tkrmagid.chatanswer mod_group=kr.tkrmagid.chatanswer
mod_name=채팅정답 mod_name=채팅정답