mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-12-11 16:31:01 -05:00
18 lines
508 B
JavaScript
18 lines
508 B
JavaScript
var mc = require('../');
|
|
var client = mc.createClient({
|
|
username: process.env.MC_USERNAME,
|
|
email: process.env.MC_EMAIL,
|
|
password: process.env.MC_PASSWORD,
|
|
verbose: true,
|
|
});
|
|
client.on('connect', function() {
|
|
console.info("connected");
|
|
});
|
|
client.on('packet-3', function(packet) {
|
|
var match = packet.message.match(/^<(.+?)> (.*)$/);
|
|
if (! match) return;
|
|
var username = match[1];
|
|
var msg = match[2];
|
|
if (username === client.username) return;
|
|
client.writePacket(0x03, {message: msg});
|
|
});
|