UNPKG

bedrock-api

Version:

A Node.js library to retrieve information about a Minecraft Bedrock Edition server using its IP address and port.

26 lines (20 loc) 548 B
'use strict'; const ByteBuffer = require('bytebuffer'); const {RAKNET} = require("../config"); class UnconnectedPing { constructor(pingId) { this.bb = new ByteBuffer(); this.bb.buffer[0] = RAKNET.UNCONNECTED_PING; this.bb.offset = 1; this.pingId = pingId; } encode() { this.bb .writeLong(this.pingId) .append(RAKNET.MAGIC, 'hex') .writeLong(0) .flip() .compact(); } } module.exports = UnconnectedPing;