mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 06:03:33 -04:00
update example code with new packet specific events
This commit is contained in:
parent
796cb76435
commit
fa1a8db52a
@ -38,8 +38,7 @@ var client = mc.createClient({
|
||||
email: "email@example.com", // email and password are required only for
|
||||
password: "12345678", // online-mode=true servers
|
||||
});
|
||||
client.on('packet', function(packet) {
|
||||
if (packet.id !== 0x03) return;
|
||||
client.on('packet-3', function(packet) {
|
||||
if (packet.message.indexOf(client.session.username) !== -1) return;
|
||||
client.writePacket(0x03, {
|
||||
message: packet.message,
|
||||
|
@ -8,8 +8,7 @@ var client = mc.createClient({
|
||||
client.on('connect', function() {
|
||||
console.info("connected");
|
||||
});
|
||||
client.on('packet', function(packet) {
|
||||
if (packet.id !== 0x03) return;
|
||||
client.on('packet-3', function(packet) {
|
||||
var match = packet.message.match(/^<(.+?)> (.*)$/);
|
||||
if (! match) return;
|
||||
var username = match[1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user