Update example, remove mention of test coverage output

This commit is contained in:
roblabla 2015-09-24 12:28:41 +02:00
parent f7e50721e8
commit 5e810d3b81

View File

@ -25,7 +25,7 @@ Parse and serialize minecraft packets, plus authentication and encryption.
- Handshake - Handshake
- Keep-alive checking - Keep-alive checking
- Ping status - Ping status
* Robust test coverage. See Test Coverage section below. * Robust test coverage.
* Optimized for rapidly staying up to date with Minecraft protocol updates. * Optimized for rapidly staying up to date with Minecraft protocol updates.
## Projects Using node-minecraft-protocol ## Projects Using node-minecraft-protocol
@ -53,13 +53,11 @@ var client = mc.createClient({
client.on('chat', function(packet) { client.on('chat', function(packet) {
// Listen for chat messages and echo them back. // Listen for chat messages and echo them back.
var jsonMsg = JSON.parse(packet.message); var jsonMsg = JSON.parse(packet.message);
if (jsonMsg.translate == 'chat.type.announcement' || jsonMsg.translate == 'chat.type.text') { if(jsonMsg.translate == 'chat.type.announcement' || jsonMsg.translate == 'chat.type.text') {
var username = jsonMsg.using[0]; var username = jsonMsg.with[0].text;
var msg = jsonMsg.using[1]; var msg = jsonMsg.with[1];
if (username === client.username) return; if(username === client.username) return;
client.write("chat", { client.write('chat', {message: msg});
message: msg
});
} }
}); });
``` ```
@ -83,7 +81,8 @@ server.on('login', function(client) {
gameMode: 0, gameMode: 0,
dimension: 0, dimension: 0,
difficulty: 2, difficulty: 2,
maxPlayers: server.maxPlayers maxPlayers: server.maxPlayers,
reducedDebugInfo: false
}); });
client.write('position', { client.write('position', {
x: 0, x: 0,
@ -91,13 +90,16 @@ server.on('login', function(client) {
z: 0, z: 0,
yaw: 0, yaw: 0,
pitch: 0, pitch: 0,
onGround: true flags: 0x00
}); });
var msg = { translate: 'chat.type.announcement', using: [ var msg = {
'Server', translate: 'chat.type.announcement',
'Hello, ' + client.username "with": [
]}; 'Server',
client.write("chat", { message: JSON.stringify(msg) }); 'Hello, world!'
]
};
client.write("chat", { message: JSON.stringify(msg), position: 0 });
}); });
``` ```