leejunyoung5819 mc-paper-plugin-test-mcp-26.3
공개마인크래프트 26.3 Paper 서버의 플러그인 테스트를 하려는 AI 에이전트를 위한 MCP 도구
| 1 | package dev.mctester.bridge; |
| 2 | |
| 3 | import net.fabricmc.api.ClientModInitializer; |
| 4 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; |
| 5 | import org.slf4j.Logger; |
| 6 | import org.slf4j.LoggerFactory; |
| 7 | |
| 8 | /** |
| 9 | * Entry point. The bridge only activates when the harness passes a port |
| 10 | * (-Dqabridge.port=N or QA_BRIDGE_PORT), so the jar is inert in a normal client. |
| 11 | */ |
| 12 | public class QaBridgeClient implements ClientModInitializer { |
| 13 | public static final Logger LOG = LoggerFactory.getLogger("qa-bridge"); |
| 14 | public static final boolean ACCEPT_SERVER_PACKS = Boolean.parseBoolean(System.getProperty("qabridge.acceptServerPacks", "false")); |
| 15 | public static final boolean HIDE_TOASTS = Boolean.parseBoolean(System.getProperty("qabridge.hideToasts", "false")); |
| 16 | |
| 17 | @Override |
| 18 | public void onInitializeClient() { |
| 19 | String raw = System.getProperty("qabridge.port"); |
| 20 | if (raw == null) raw = System.getenv("QA_BRIDGE_PORT"); |
| 21 | if (raw == null || raw.isBlank()) { |
| 22 | LOG.info("qa-bridge: no port configured, staying disabled"); |
| 23 | return; |
| 24 | } |
| 25 | int port = Integer.parseInt(raw.trim()); |
| 26 | ChatLog.register(); |
| 27 | Ticks.register(); |
| 28 | try { |
| 29 | BridgeServer srv = new BridgeServer(port); |
| 30 | srv.start(); |
| 31 | ClientLifecycleEvents.CLIENT_STOPPING.register(mc -> srv.stop()); |
| 32 | LOG.info("qa-bridge: listening on 127.0.0.1:{}", port); |
| 33 | } catch (Exception e) { |
| 34 | LOG.error("qa-bridge: failed to start HTTP server on port {}", port, e); |
| 35 | } |
| 36 | } |
| 37 | } |