Change how authentication gets passed

I was making a launcher of my own, and I found it very hard to juggle with having the auth in the options since I needed to set the client events before I actaully had the users login. This will fix the issue i was running into!
This commit is contained in:
Pierce 2019-05-23 20:40:44 -04:00
parent 69ec61f56e
commit 3f0ceae5b6
3 changed files with 16 additions and 5 deletions

View file

@ -14,7 +14,15 @@ class MCLCore extends EventEmitter {
this.pid = null;
}
async launch() {
async launch(authorization) {
if(!authorization) throw Error('No authorization to launch the client with!');
if({}.toString.call(authorization) === "[object Promise]") {
this.options.authorization = await authorization;
} else {
this.options.authorization = authorization
}
this.options.root = path.resolve(this.options.root);
if(!fs.existsSync(this.options.root)) {
this.emit('debug', '[MCLC]: Attempting to create root folder');