Returns a Server
instance and starts listening. All clients will be
automatically logged in and validated against mojang's auth.
options
is an object containing the properties :
- port : default to 25565
- host : default to localhost
- kickTimeout : default to
10*1000
(10s), kick client that doesn't answer to keepalive after that time - checkTimeoutInterval : default to
4*1000
(4s), send keepalive packet at that period - online-mode : default to true
- beforePing : allow customisation of the answer to ping the server does. It takes a function with argument response and client, response is the default json response, and client is client who sent a ping. It can take as third argument a callback. If the callback is passed, the function should pass its result to the callback, if not it should return.
- motd : default to "A Minecraft server"
- maxPlayers : default to 20
- keepAlive : send keep alive packets : default to true
- version : 1.8 or 1.9 : default to 1.8
Create a server instance for version
of minecraft.
This is a plain old JavaScript object. Add a key with the username you want to be exempt from online mode or offline mode (whatever mode the server is in).
Make sure the entries in this object are all lower case.
Javascript object mapping a Client
from a clientId.
The amount of players currently present on the server.
The maximum amount of players allowed on the server.
The motd that is sent to the player when he is pinging the server
A base64 data string representing the favicon that will appear next to the server on the mojang client's multiplayer list.
Called when a client connects, but before any login has happened. Takes a
Client
parameter.
Called when a client is logged in against server. Takes a Client
parameter.
Returns a Client
instance and perform login.
options
is an object containing the properties :
- username
- port : default to 25565
- password : can be omitted (if the tokens are also omitted then it tries to connect in offline mode)
- host : default to localhost
- clientToken : generated if a password is given
- accessToken : generated if a password is given
- keepAlive : send keep alive packets : default to true
- checkTimeoutInterval : default to
10*1000
(10s), check if keepalive received at that period, disconnect otherwise. - version : 1.8 or 1.9 : default to 1.8
Create a new client, if isServer
is true then it is a server-side client, otherwise it's a client-side client.
Takes a minecraft version
as second argument.
The internal state that is used to figure out which protocol state we are in during packet parsing. This is one of the protocol.states.
True if this is a connection going from the server to the client, False if it is a connection from client to server.
Returns the internal nodejs Socket used to communicate with this client.
A string representation of the client's UUID. Note that UUIDs are unique for each players, while playerNames, as of 1.7.7, are not unique and can change.
The user's username.
The user's session, as returned by the Yggdrasil system. (only client-side)
The player's profile, as returned by the Yggdrasil system. (only server-side)
The latency of the client, in ms. Updated at each keep alive.
Called with every packet parsed. Takes two params, the JSON data we parsed, and the packet metadata (name, state)
Called with every packet, but as a buffer. Takes two params, the buffer and the packet metadata (name, state)
Called when the protocol changes state. Takes the new state and old state as parameters.
Check out the minecraft-data docs to know the event names and data field names.
Note : almost all data formats can be understood by looking at minecraft-data docs or minecraft-data protocol.json
Value looks like this:
[
{type: 1, value: 2, key: 3},
{type: 2, value: 3, key: 4},
...
]
Where the key is the numeric metadata key and the value is the value of the correct data type. You can figure out the types here
callback(err, pingResults)
pingResults
:
prefix
protocol
version
motd
playerCount
maxPlayers
description
players
max
online
sample
id
name
version
name
protocol
favicon
latency
The minecraft protocol states.
The supported minecraft versions.
Returns a minecraft protocol serializer for these parameters.
mc.createDeserializer({ state = states.HANDSHAKING, isServer = false, packetsToParse = {"packet": true}, version })
Returns a minecraft protocol deserializer for these parameters.