1.0.13 • Published 2 years ago

minecraft-query v1.0.13

Weekly downloads
55
License
GPL-3.0
Repository
github
Last release
2 years ago

query

A Node.js implementation of Minecraft's query protocol

Installation

npm install minecraft-query

Prerequisites

You will first have to configure your server to recieve queries from clients. To do so, set the enable-query flag to true in your server.properties file and then set the query.port flag as you wish. The configuration should look like this

...
enable-query=true
query.port=<1-65535>
...

Example use

const Query = require("minecraft-query");

const q = new Query({host: 'localhost', port: 9630, timeout: 7500});

q.fullStat()
  .then(success => {

    console.log(success);

    return q.basicStat()

  })

  .then(success => {

    console.log(success);

    q.close();

  })

API

class Query({host, port, timeout})

Arguments:
  • host: the address of the server
  • port: the query port of the server
  • timeout: handshake timeout in ms (default 5000)

It returns a Query instance.

Query#basicStat()

Arguments:
  • none

A promise that returns an object that corresponds to the basic stat query type. The object should look like this:

{ 
  motd: 'MOTD here',
  gametype: 'SMP',
  map: 'world',
  online_players: '0',
  max_players: '20' 
}

Query#close()

Arguments:
  • none

It ends the connection

Query#fullStat()

Arguments:
  • none

A promise that returns an object that corresponds to the full stat query type. The object should look like this:

{ 
  motd: 'MOTD here',
  gametype: 'SMP',
  game_id: 'MINECRAFT',
  version: '1.14.2',
  plugins: 'Paper on 1.14.2-R0.1-SNAPSHOT',
  map: 'world',
  online_players: '4',
  max_players: '20',
  port: '9630',
  players: ['macca_ferri', 'player1', 'notch', 'jeb'] 
}
1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago