UNPKG

@xmcl/client

Version:

Minecraft socket pipeline utilities. Support Minecraft lan server discovery.

120 lines 3.01 kB
import { TextComponent } from '@xmcl/text-component'; import { Channel } from './channel'; export declare class Handshake { protocolVersion: number; serverAddress: string; serverPort: number; nextState: number; } export declare class ServerQuery { } export declare class ServerStatus { status: Status; } export declare class Ping { time: bigint; } export declare class Pong { ping: bigint; } /** * The json format for Minecraft server handshake status query response */ export interface Status { /** * The version info of the server */ version: { /** * The name of the version, might be standard version, like 1.14.4. * Or it can be modified content, just be any string the server hoster like. */ name: string; /** * The protocol version */ protocol: number; }; /** * The player info in server */ players: { /** * The server max player capacity */ max: number; /** * The current online player number */ online: number; /** * The online player info */ sample?: Array<GameProfile>; }; /** * The motd of server, which might be the raw TextComponent string or structurelized TextComponent JSON */ description: TextComponent | string; /** * The base 64 favicon data */ favicon: string | ''; modinfo?: { type: string | 'FML'; modList: Array<ForgeModIdentity>; }; /** * The ping from server */ ping: number; } interface GameProfile { name: string; id: string; } interface ForgeModIdentity { readonly modid: string; readonly version: string; } export interface QueryOptions { /** * see http://wiki.vg/Protocol_version_numbers */ protocol?: number; /** * timeout milliseconds */ timeout?: number; retryTimes?: number; } /** * Create a channel with Handleshake, ServerQuery, ServerStatus, Ping, Pong packets are registered. * * This is a lower level function for the case that you want to use channel directly * * @see {@link Channel} */ export declare function createChannel(): Channel; /** * Query the server status in raw JSON format in one shot. * * @param server The server information * @param options The query options */ export declare function queryStatus(server: { host: string; port?: number; }, options?: QueryOptions): Promise<Status>; /** * Create a query client for certain protocol and timeout setting. * @param protocol The protocol number * @param timeout The timeout millisecond */ export declare function createClient(protocol: number, timeout?: number): { readonly channel: Channel; protocol: number; query(host: string, port?: number): Promise<Status>; }; export {}; //# sourceMappingURL=status.d.ts.map