mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-12-20 04:22:22 -05:00
0134f1599f
* fix custom channel registation * update channel examples * use actual protocol version * update custom channel examples * use default host & port * select channel name based on the feature set
24 lines
839 B
JavaScript
24 lines
839 B
JavaScript
const mc = require('minecraft-protocol')
|
|
|
|
if (process.argv.length < 4 || process.argv.length > 6) {
|
|
console.log('Usage : node client_channel.js <host> <port> [<name>] [<password>]')
|
|
process.exit(1)
|
|
}
|
|
|
|
const client = mc.createClient({
|
|
host: process.argv[2],
|
|
port: parseInt(process.argv[3]),
|
|
username: process.argv[4] ? process.argv[4] : 'test',
|
|
password: process.argv[5],
|
|
version: false
|
|
})
|
|
|
|
client.on('login', onlogin)
|
|
client.on('error', console.log)
|
|
|
|
function onlogin () {
|
|
client.registerChannel('node-minecraft-protocol:custom_channel_one', ['string', []], true)
|
|
client.registerChannel('node-minecraft-protocol:custom_channel_two', ['string', []], true)
|
|
client.writeChannel('node-minecraft-protocol:custom_channel_one', 'hello from the client')
|
|
client.on('node-minecraft-protocol:custom_channel_two', console.log)
|
|
}
|