mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-27 21:24:25 -04:00
fix client_echo example
This commit is contained in:
parent
2c93a4e796
commit
272a28701c
@ -1,17 +1,24 @@
|
||||
var mc = require('../../')
|
||||
, states = mc.states
|
||||
var mc = require('../../');
|
||||
|
||||
if(process.argv.length < 4 || process.argv.length > 6) {
|
||||
console.log("Usage : node echo.js <host> <port> [<name>] [<password>]");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var client = mc.createClient({
|
||||
username: process.env.MC_USERNAME,
|
||||
password: process.env.MC_PASSWORD,
|
||||
host: process.argv[2],
|
||||
port: parseInt(process.argv[3]),
|
||||
username: process.argv[4] ? process.argv[4] : "echo",
|
||||
password: process.argv[5]
|
||||
});
|
||||
|
||||
client.on('connect', function() {
|
||||
console.info('connected');
|
||||
});
|
||||
client.on('chat', function(packet) {
|
||||
var jsonMsg = JSON.parse(packet.message);
|
||||
if(jsonMsg.translate == 'chat.type.announcement' || jsonMsg.translate == 'chat.type.text') {
|
||||
var username = jsonMsg.with[0];
|
||||
var username = jsonMsg.with[0].text;
|
||||
var msg = jsonMsg.with[1];
|
||||
if(username === client.username) return;
|
||||
client.write('chat', {message: msg});
|
||||
|
Loading…
x
Reference in New Issue
Block a user