1.1.5 ā€¢ Published 5 months ago

minecraftstatuspinger v1.1.5

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
5 months ago

What can this be used for?

  • Getting server Latency (ping)
  • Getting server MOTD
  • Downloading server Thumbnail (favicon)
  • Viewing Server Version
  • Fetching Player Count and Playerlist

Getting started

Requirements

  • NodeJS or Deno (used to run JavaScript code)
  • NPM (used to install Node packages)

Installation

npm install minecraftstatuspinger

Basic Example

import mc from "minecraftstatuspinger";

let result = await mc.lookup({ host: "mc.hypixel.net" })
console.log(result);
import mc from "minecraftstatuspinger";

let result = await mc.lookup({
    host: "mc.hypixel.net",
    port: 25565,
    ping: true,
    protocolVersion: 764,
    timeout: 10000,
    throwOnParseError: true,
    disableSRV: false,
    disableJSONParse: false
})

console.log(result);

Docs

  • .lookup(): ((options: ServerStatusOptions) => Promise<ServerStatus>)

    • options: ServerStatusOptions
      • host: string

        Either an IP, or a hostname of the server. (alias: hostname)

      • port?: number default: 25565

        Port of the server. Any port other than 25565 disables SRV lookup.

      • timeout?: number default: 10000

        Timeout of when an error is thrown after no response. Default is 10 seconds.

      • ping?: boolean default: true

        Whether to send a payload at the end to get the latency of the server. If false, the latency field will be null.

      • protocolVersion?: number default: 764

        Protocol version to send to the server to simulate different Minecraft client versions. Here, you can see the Protocol Version Numbers. The current default protocol version is for 1.20.2 (764) and will be irregularly updated to newer versions.

      • throwOnParseError?: boolean default: true

        Whether to throw an error if the status packet fails to parse the status field. The statusRaw field is always included.

      • disableSrv?: boolean default: false

        Whether to force skip SRV lookups. Useful when only pinging IP addresses and not hostnames.

      • disableJSONParse?: boolean default: false

        Whether to skip JSON parsing. Useful if you only want the raw text response. If true, the status field to be undefined.

    • ServerStatus
      • latency?: number

        The time it takes to send and receive a payload from the server. Will be null if ping option is false.

      • status?: DynamicObject

        Parsed status response from the sever. Will be null if the status fails to parse, or if disableJSONParse is true. Example of a valid Status Response.

      • statusRaw: string

        Raw status response in the form of a string. Useful when status fails to parse.

  • .setDnsServers(): ((serverArray: string[]) => Promise<boolean>)

    It wraps the dns.setServers function, ueful when you want to look up the SRV records with different DNS servers. The first IP in the array is always the main DNS server, others are backup servers. Pass in a parameter which is an array of hostnames or IP addresses of DNS servers. It will either return true, or throw an error.

    Usage:

      // For example:
      mc.setDnsServers(["9.9.9.9", "1.1.1.1", "8.8.8.8"])
      // (Quad9, Cloudflare, Google)
      // Cloudflare is the fastest for DNS queries in most of the world.

    If you never changed the DNS settings of your computer, the default DNS server will be your ISP's. ā— I recommend changing your default DNS servers if you're doing thousands of lookups, for better performance.

Changelog

View Changelog, Latest version: v1.1.4

Contact

If you have some questions, you can message me through Discord - woodendoors7

Acknowledgements

TINY Readme

To-do

  • Do SRV lookups
  • Support versions less than 1.7.
  • Support Bedrock

License

This project is licensed under the GNU General Public License v3.0.

1.1.5

5 months ago

1.1.5-dev

5 months ago

1.1.4

5 months ago

0.1.4-dev

5 months ago

1.1.3

6 months ago

1.1.2

7 months ago

1.1.3-dev

6 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.1

12 months ago

1.0.0

12 months ago

1.0.5

10 months ago

1.0.4

12 months ago

1.0.3

12 months ago

0.1.2-dev

1 year ago

0.1.1-dev

1 year ago