mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-12-20 04:22:22 -05:00
28093fb1fb
* Add docs * Implement Realm joining * Check for Microsoft auth * Remove on chat event * Add realmName option to example * Passthrough client to `realmAuthenticate` * Fix overwriting existing authflow * Don't use `??=` * Lint
25 lines
754 B
JavaScript
25 lines
754 B
JavaScript
'use strict'
|
|
|
|
const mc = require('minecraft-protocol')
|
|
|
|
const [,, username, realmName] = process.argv
|
|
if (!realmName) {
|
|
console.log('Usage : node client_realms.js <username/email> <realm_name>')
|
|
process.exit(1)
|
|
}
|
|
|
|
const client = mc.createClient({
|
|
realms: {
|
|
// realmId: '1234567', // Connect the client to a Realm using the Realms ID
|
|
pickRealm: (realms) => realms.find(e => e.name === realmName) // Connect the client to a Realm using a function that returns a Realm
|
|
},
|
|
username,
|
|
auth: 'microsoft' // This option must be present and set to 'microsoft' to join a Realm.
|
|
})
|
|
|
|
client.on('connect', function () {
|
|
console.info('connected')
|
|
})
|
|
client.on('disconnect', function (packet) {
|
|
console.log('disconnected: ' + packet.reason)
|
|
})
|