Skip to content

Commit

Permalink
update package.json, send handshake and status request separately
Browse files Browse the repository at this point in the history
  • Loading branch information
KurtThiemann committed Nov 7, 2024
1 parent 15c0708 commit 70fe4d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "craftping",
"type": "module",
"version": "1.0.2",
"version": "1.0.3",
"main": "index.js",
"repository": "github:aternosorg/craftping",
"scripts": {
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --rootDir ./test"
},
"keywords": ["minecraft", "ping", "query", "status", "protocol"],
"author": "",
"author": "Kurt Thiemann <[email protected]>",
"license": "MIT",
"description": "",
"description": "A universal ping/query library for Minecraft servers.",
"devDependencies": {
"@jest/globals": "^29.7.0",
"jest": "^29.7.0"
Expand Down
13 changes: 6 additions & 7 deletions src/JavaPing/JavaPing.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ export default class JavaPing extends TCPSocket {
*/
async ping(options = {}) {
let time = BigInt(Date.now());
await this.write(Buffer.concat([
new Handshake()
.setProtocolVersion(options.protocolVersion ?? null)
.setHostname(options.hostname ?? this.address)
.setPort(options.port ?? this.port).write(),
new StatusRequest().write()
]));
await this.write(new Handshake()
.setProtocolVersion(options.protocolVersion ?? null)
.setHostname(options.hostname ?? this.address)
.setPort(options.port ?? this.port).write());
this.signal?.throwIfAborted();
await this.write(new StatusRequest().write());
this.signal?.throwIfAborted();

let response = await this.readPacket(StatusResponse);
Expand Down

0 comments on commit 70fe4d9

Please sign in to comment.