mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-12-02 12:06:53 -05:00
df3f95e1ff
This change breaks backwards compatibility. `createClient` no longer takes an `email` argument. Instead, the `username` argument is used to authenticate and determine the case correct username. There is a special case if you leave out the `password` argument. In this case, `username` is used to connect directly to the server, and you may get kicked if the server is in online mode.
16 lines
448 B
JavaScript
16 lines
448 B
JavaScript
var mc = require('../');
|
|
var client = mc.createClient({
|
|
username: process.env.MC_USERNAME,
|
|
password: process.env.MC_PASSWORD,
|
|
});
|
|
client.on('connect', function() {
|
|
console.info("connected");
|
|
});
|
|
client.on(0x03, function(packet) {
|
|
var match = packet.message.match(/^<(.+?)> (.*)$/);
|
|
if (! match) return;
|
|
var username = match[1];
|
|
var msg = match[2];
|
|
if (username === client.username) return;
|
|
client.write(0x03, {message: msg});
|
|
});
|