Add player-join hook to signal mod presence to datapack (v1.1.0)
ChatAnswerCore.onPlayerJoin 이 storage chat_answer:status active=1b 를 set. Fabric 측은 ServerPlayConnectionEvents.JOIN, NeoForge 측은 PlayerLoggedInEvent 에서 호출. 데이터팩이 mq:load 단계에서 0b 로 clear 해 두므로, 모드가 빠진 환경에선 이 hook 이 일어나지 않아 0b 가 유지되고, 모드가 있으면 첫 로그인 직후 1b 로 갱신되어 데이터팩이 활성 상태를 분기할 수 있다.
This commit is contained in:
@@ -3,6 +3,7 @@ package kr.tkrmagid.chatanswer.fabric;
|
||||
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;
|
||||
|
||||
public final class ChatAnswerFabric implements ModInitializer {
|
||||
@Override
|
||||
@@ -10,5 +11,8 @@ public final class ChatAnswerFabric implements ModInitializer {
|
||||
ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) ->
|
||||
ChatAnswerCore.handleChat(sender, message.signedContent())
|
||||
);
|
||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) ->
|
||||
ChatAnswerCore.onPlayerJoin(handler.player)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user