diff --git a/README.md b/README.md index ec0a912..0b861e4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Parse and serialize minecraft packets, plus authentication and encryption. ## Features - * Supports Minecraft version 1.8.1 + * Supports Minecraft version 1.8.8 * Parses all packets and emits events with packet fields as JavaScript objects. * Send a packet by supplying fields as a JavaScript object. @@ -122,143 +122,6 @@ See [doc](doc/README.md) * Download the appropriate version of `minecraft_server.jar`. * `MC_SERVER_JAR=path/to/minecraft_server.jar MC_USERNAME=email@example.com MC_PASSWORD=password npm test` -### Test Coverage - -``` - - packets - ✓ handshaking,ServerBound,0x00 - ✓ status,ServerBound,0x00 - ✓ status,ServerBound,0x01 - ✓ status,ClientBound,0x00 - ✓ status,ClientBound,0x01 - ✓ login,ServerBound,0x00 - ✓ login,ServerBound,0x01 - ✓ login,ClientBound,0x00 - ✓ login,ClientBound,0x01 - ✓ login,ClientBound,0x02 - ✓ login,ClientBound,0x03 - ✓ play,ServerBound,0x00 - ✓ play,ServerBound,0x01 - ✓ play,ServerBound,0x02 - ✓ play,ServerBound,0x03 - ✓ play,ServerBound,0x04 - ✓ play,ServerBound,0x05 - ✓ play,ServerBound,0x06 - ✓ play,ServerBound,0x07 - ✓ play,ServerBound,0x08 - ✓ play,ServerBound,0x09 - ✓ play,ServerBound,0x0a - ✓ play,ServerBound,0x0b - ✓ play,ServerBound,0x0c - ✓ play,ServerBound,0x0d - ✓ play,ServerBound,0x0e - ✓ play,ServerBound,0x0f - ✓ play,ServerBound,0x10 - ✓ play,ServerBound,0x11 - ✓ play,ServerBound,0x12 - ✓ play,ServerBound,0x13 - ✓ play,ServerBound,0x14 - ✓ play,ServerBound,0x15 - ✓ play,ServerBound,0x16 - ✓ play,ServerBound,0x17 - ✓ play,ServerBound,0x18 - ✓ play,ServerBound,0x19 - ✓ play,ClientBound,0x00 - ✓ play,ClientBound,0x01 - ✓ play,ClientBound,0x02 - ✓ play,ClientBound,0x03 - ✓ play,ClientBound,0x04 - ✓ play,ClientBound,0x05 - ✓ play,ClientBound,0x06 - ✓ play,ClientBound,0x07 - ✓ play,ClientBound,0x08 - ✓ play,ClientBound,0x09 - ✓ play,ClientBound,0x0a - ✓ play,ClientBound,0x0b - ✓ play,ClientBound,0x0c - ✓ play,ClientBound,0x0d - ✓ play,ClientBound,0x0e - ✓ play,ClientBound,0x0f - ✓ play,ClientBound,0x10 - ✓ play,ClientBound,0x11 - ✓ play,ClientBound,0x12 - ✓ play,ClientBound,0x13 - ✓ play,ClientBound,0x14 - ✓ play,ClientBound,0x15 - ✓ play,ClientBound,0x16 - ✓ play,ClientBound,0x17 - ✓ play,ClientBound,0x18 - ✓ play,ClientBound,0x19 - ✓ play,ClientBound,0x1a - ✓ play,ClientBound,0x1b - ✓ play,ClientBound,0x1c - ✓ play,ClientBound,0x1d - ✓ play,ClientBound,0x1e - ✓ play,ClientBound,0x1f - ✓ play,ClientBound,0x20 - ✓ play,ClientBound,0x21 - ✓ play,ClientBound,0x22 - ✓ play,ClientBound,0x23 - ✓ play,ClientBound,0x24 - ✓ play,ClientBound,0x25 - ✓ play,ClientBound,0x26 - ✓ play,ClientBound,0x27 - ✓ play,ClientBound,0x28 - ✓ play,ClientBound,0x29 - ✓ play,ClientBound,0x2a - ✓ play,ClientBound,0x2b - ✓ play,ClientBound,0x2c - ✓ play,ClientBound,0x2d - ✓ play,ClientBound,0x2e - ✓ play,ClientBound,0x2f - ✓ play,ClientBound,0x30 - ✓ play,ClientBound,0x31 - ✓ play,ClientBound,0x32 - ✓ play,ClientBound,0x33 - ✓ play,ClientBound,0x34 - ✓ play,ClientBound,0x35 - ✓ play,ClientBound,0x36 - ✓ play,ClientBound,0x37 - ✓ play,ClientBound,0x38 - ✓ play,ClientBound,0x39 - ✓ play,ClientBound,0x3a - ✓ play,ClientBound,0x3b - ✓ play,ClientBound,0x3c - ✓ play,ClientBound,0x3d - ✓ play,ClientBound,0x3e - ✓ play,ClientBound,0x3f - ✓ play,ClientBound,0x40 - ✓ play,ClientBound,0x41 - ✓ play,ClientBound,0x42 - ✓ play,ClientBound,0x43 - ✓ play,ClientBound,0x44 - ✓ play,ClientBound,0x45 - ✓ play,ClientBound,0x46 - ✓ play,ClientBound,0x47 - ✓ play,ClientBound,0x48 - ✓ play,ClientBound,0x49 - - client - ✓ pings the server (65754ms) - ✓ connects successfully - online mode (STUBBED) - ✓ connects successfully - offline mode (STUBBED) - ✓ gets kicked when no credentials supplied in online mode (67167ms) - ✓ does not crash for 10000ms (69597ms) - - mc-server - ✓ starts listening and shuts down cleanly - ✓ kicks clients that do not log in (133ms) - ✓ kicks clients that do not send keepalive packets (122ms) - ✓ responds to ping requests - ✓ clients can log in and chat (39ms) - ✓ kicks clients when invalid credentials (8430ms) - ✓ gives correct reason for kicking clients when shutting down (42ms) - - - 123 tests complete (4 minutes) -``` - ## Debugging You can enable some protocol debugging output using `NODE_DEBUG` environment variable: diff --git a/doc/README.md b/doc/README.md index 75dce5b..4c2f8a6 100644 --- a/doc/README.md +++ b/doc/README.md @@ -30,38 +30,48 @@ ## mc.createServer(options) -Returns a `Server` instance and starts listening. +Returns a `Server` instance and starts listening. All clients will be +automatically logged in and validated against mojang's auth. ## Server -## server.onlineModeExceptions +### server.onlineModeExceptions 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. -## server.clients +### server.clients Javascript object mapping a `Client` from a clientId. -## server.playerCount +### server.playerCount The amount of players currently present on the server. -## server.maxPlayers +### server.maxPlayers The maximum amount of players allowed on the server. -## server.motd +### server.motd The motd that is sent to the player when he is pinging the server -## server.favicon +### server.favicon A base64 data string representing the favicon that will appear next to the server on the mojang client's multiplayer list. +### `connection` event + +Called when a client connects, but before any login has happened. Takes a +`Client` parameter. + +### `login` event + +Called when a client is logged in against server. Takes a `Client` parameter. + ## mc.createClient(options) Returns a `Client` instance and perform login. @@ -77,34 +87,53 @@ Returns a `Client` instance and perform login. ## Client -## client.state +### client.state 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. -## client.isServer +### client.isServer True if this is a connection going from the server to the client, False if it is a connection from client to server. -## client.socket +### client.socket Returns the internal nodejs Socket used to communicate with this client. -## client.uuid +### client.uuid 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. -## client.username +### client.username The user's username. -## client.session +### client.session The user's session, as returned by the Yggdrasil system. +### `packet` event + +Called with every packet parsed. Takes two params, the JSON data we parsed, +and the packet metadata (name, id, state) + +### `raw` event + +Called with every packet, but as a buffer. Takes two params, the buffer +and the packet metadata (name, id, state) + +### `state` event + +Called when the protocol changes state. Takes the new state and old state as +parameters. + +### per-packet events + +Check out the [minecraft-data docs](https://prismarinejs.github.io/minecraft-data/?v=1.8&d=protocol) to know the event names and data field names. + ## Not Immediately Obvious Data Type Formats Note : almost all data formats can be understood by looking at the packet @@ -116,11 +145,11 @@ Value looks like this: ```js [ - {type: 'slot', value: slot, key: 3}, - {type: 'int', value: value, key: 4}, + {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. +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](http://wiki.vg/Entities#Entity_Metadata_Format)