mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-12-01 11:37:04 -05:00
19 lines
565 B
JavaScript
19 lines
565 B
JavaScript
var mc = require('../../')
|
|
, states = mc.states
|
|
|
|
var client = mc.createClient({
|
|
username: process.env.MC_USERNAME,
|
|
password: process.env.MC_PASSWORD,
|
|
});
|
|
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 msg = jsonMsg.with[1];
|
|
if(username === client.username) return;
|
|
client.write('chat', {message: msg});
|
|
}
|
|
});
|