J

mcperadar

...
Created 7/5/2015byfalkirks

Language:

JavaScript

Stars:

3

Forks:

0

NPM version Build Status Dependency Status

Scan for Minecraft Pocket Edition (MCPE) servers in local network. This includes vanilla MCPE clients and PocketMine servers.

This library allows you to find MCPE servers on your local network. These "servers" may be referred to as "clients", as they are clients on the mcperadar application. This might be a bit confusing.

Install

$ npm install --save mcperadar

Package

var mcperadar = require('mcperadar');

//
// Listen to every PONG packet that is received
//
mcperadar.on('message', function(data){
  console.log(data);
});

//
// Called when a new client is discovered. A new client is a client whose clientId hasn't appeared in the current instance.
//
mcperadar.on('discover', function(data){
  console.log(data);
});

//
// Called when a client fails to respond to a PING with CLIENT_TIMEOUT milliseconds.
//
mcperadar.on('disconnect', function(data){
  console.log(data);
});

//
// Called whenever a client re-establishes a connection after
// being marked as disconnected.
//
mcperadar.on('reconnect', function(data){
  console.log(data);
});

//
// Called anytime a client opens a connection (ie: marked as connected). 
// This included 'discover' and 'reconnect'
//
mcperadar.on('connect', function(data){
  console.log(data);
});

Client object

The client object is emmited to all events. rinfo is taken directly from the dgram package. The pingId is the time the packet was sent and the ackId is the time it was received. Times are relative to START_TIME and is measured in milliseconds.

{
    rinfo: { address: "192.168.1.22", port: 19132 },
    advertise: "mcpe;Steve;27;0.11.0;1;5",
    serverId: "ID-of-MCPE-installation",
    pingId: 1,
    game: "mcpe",
    version: "0.11.0",
    name: "Steve",
    currentPlayers: 1,
    maxPlayers: 5,
    ackId: 25,
    connected: true
}
            ### Client IDs

Client IDs identify each client internally and help determine which session a PONG packet belongs to. The ID is formed using an MD5 hash of the server id (as sent in the PONG packet), the client IP and the client port. This means that if the client's name changes, it will still have the same ID internally.

CLI

The CLI is a work in progress. As of writing, it is able to print out API events as they happen. Eventually, it should have the ability to list clients out in a pretty table and update them as events come in.

$ npm install --global mcperadar
$ mcperadar --help

License

MIT © Falkirks

Last updated: 7/10/2024

Publisher info

falkirks's avatar

I write beautiful code...sometimes it even compiles. (profile picture by milosh)

@stripe
302
followers
112
following
139
repos

More MCP servers built with JavaScript

emergency-medicare-planner-mcp-server

emergency-medicare-planner-mcp-server

By manolaz1
mcp-warpcast-server

MCP Server for Warpcast integration

By zhangzhongnan9281
mcp-tavily-server

Tavily MCP Server for Cline

By dkmaker1