UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

112 lines (111 loc) 3.32 kB
import { IEvent } from "ste-events"; import { DebugConnectionState, IDebugSessionInfo, IProfilerCaptureEvent, IProtocolEvent, IPrintEvent, IStatData, IStoppedEvent, IThreadEvent } from "./IMinecraftDebugProtocol"; export default class MinecraftDebugClient { private _socket; private _parser; private _state; private _host; private _port; private _protocolVersion; private _clientProtocolVersion; private _targetModuleUuid; private _plugins; private _capabilities; private _lastStatTick; private _errorMessage; private _passcode; private _lastDataReceivedTime; private _messageCount; private _statWarningLogged; private _statusCheckInterval; private _pendingRequests; private _requestSeq; private _onConnected; private _onDisconnected; private _onStats; private _onStopped; private _onThread; private _onPrint; private _onError; private _onProtocol; private _onProfilerCapture; get onConnected(): IEvent<MinecraftDebugClient, IDebugSessionInfo>; get onDisconnected(): IEvent<MinecraftDebugClient, string>; get onStats(): IEvent<MinecraftDebugClient, { tick: number; stats: IStatData[]; }>; get onStopped(): IEvent<MinecraftDebugClient, IStoppedEvent>; get onThread(): IEvent<MinecraftDebugClient, IThreadEvent>; get onPrint(): IEvent<MinecraftDebugClient, IPrintEvent>; get onError(): IEvent<MinecraftDebugClient, Error>; get onProtocol(): IEvent<MinecraftDebugClient, IProtocolEvent>; get onProfilerCapture(): IEvent<MinecraftDebugClient, IProfilerCaptureEvent>; get state(): DebugConnectionState; get isConnected(): boolean; get sessionInfo(): IDebugSessionInfo; constructor(); /** * Connect to the Minecraft debug server. * This method includes connection timeouts and retries to handle slow server startup. * The protocol handshake completes asynchronously after the socket connects. */ connect(host?: string, port?: number, passcode?: string): Promise<void>; private _handshakeTimeoutId; /** * Disconnect from the debug server. */ disconnect(): void; /** * Send a Minecraft command. */ sendCommand(command: string, dimensionType?: "overworld" | "nether" | "the_end"): void; /** * Resume execution (continue from breakpoint). */ resume(): void; /** * Pause execution. */ pause(): void; /** * Start the profiler. */ startProfiler(): void; /** * Stop the profiler and capture data. */ stopProfiler(capturesPath: string): void; /** * Send a message to the debug server. */ private _sendMessage; /** * Handle incoming messages. */ private _handleMessage; /** * Handle event messages from Minecraft. */ private _handleEvent; /** * Handle protocol handshake event. */ private _handleProtocolEvent; /** * Handle statistics event. */ private _handleStatEvent; /** * Flatten hierarchical stats into a flat list. */ private _flattenStats; /** * Handle response messages. */ private _handleResponse; /** * Handle disconnect. */ private _handleDisconnect; }