CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PrismarineJS

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: PrismarineJS/mineflayer
Path: blob/master/examples/session.js
Views: 789
1
// This example describes how to login using a launcher_profiles folder instead of a usual minecraft username & password
2
3
const mineflayer = require('mineflayer')
4
const path = require('path')
5
6
if (process.argv.length !== 5) {
7
console.log('Usage : node session.js <host> <port> <pathToLauncherProfiles>')
8
process.exit(1)
9
}
10
11
const profile = require(path.resolve(process.argv[4], 'launcher_profiles.json'))
12
const auth = profile.authenticationDatabase[profile.selectedUser.account]
13
const profileID = profile.selectedUser.profile
14
15
const session = {
16
accessToken: auth.accessToken,
17
clientToken: profile.clientToken,
18
selectedProfile: {
19
id: profileID,
20
name: auth.profiles[profileID].displayName
21
}
22
}
23
24
const bot = mineflayer.createBot({
25
host: process.argv[2],
26
port: parseInt(process.argv[3]),
27
session
28
})
29
30
bot.once('login', () => {
31
console.log('logged in')
32
bot.quit()
33
})
34
35