minecraftstatuspinger
Version:
A modern library for pinging Minecraft servers and getting their status and playerlist, written in TypeScript with zero dependencies.
47 lines • 1.19 kB
JavaScript
export class Packet {
constructor() {
this.status = {
handshakeBaked: false,
pingSent: false,
pingBaked: false,
pingSentTime: null,
};
this.meta = {
packetInitialized: false,
metaCrafted: false,
fieldsCrafted: false,
packetID: null,
dataLength: null,
fullLength: null,
metaLength: null,
};
this.crafted = {
data: null,
latency: null,
};
this.Error = null;
}
}
export class ServerStatus {
constructor(statusRaw, latency, throwOnParseError, JSONParse) {
if (JSONParse) {
try {
this.status = JSON.parse(statusRaw);
}
catch (err) {
if (throwOnParseError)
throw err;
this.status = null;
}
}
else
this.status = null;
this.statusRaw = statusRaw;
if (latency != null) {
this.latency = latency;
}
else
this.latency = null;
}
}
//# sourceMappingURL=types.js.map