diff --git a/README.md b/README.md index 12691d3..27e6aaf 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ https://discord.gg/8uYVbXP ### Standard Example ```javascript const { Client, Authenticator } = require('minecraft-launcher-core'); +const launcher = new Client(); let opts = { clientPackage: null, @@ -32,12 +33,10 @@ let opts = { } } -const launcher = new Client(); launcher.launch(opts); launcher.on('debug', (e) => console.log(e)); -launcher.on('data', (e) => console.log(e.toString('utf-8'))); -launcher.on('error', (e) => console.log(e.toString('utf-8'))); +launcher.on('data', (e) => console.log(e)); ``` ### Documentation @@ -159,7 +158,7 @@ You'll need to provide the folder created in the versions if you're running the | Event Name | Type | Description | |-------------------|---------|---------------------------------------------------------------------------------------| | `arguments` | Object | Emitted when launch arguments are set for the Minecraft Jar. | -| `data` | Buffer | Emitted when information is returned from the Minecraft Process | +| `data` | String | Emitted when information is returned from the Minecraft Process | | `close` | Integer | Code number that is returned by the Minecraft Process | | `package-extract` | null | Emitted when `clientPackage` finishes being extracted | | `download` | String | Emitted when a file successfully downloads | diff --git a/components/launcher.js b/components/launcher.js index 26b21f5..aec4dfc 100644 --- a/components/launcher.js +++ b/components/launcher.js @@ -29,7 +29,10 @@ class MCLCore extends EventEmitter { } }; this.handler = new handler(this); - const override = this.options.overrides; + // Lets the events register. our magic switch! + await void(0); + + this.emit('debug', `[MCLC]: MCLC version ${require(path.join(__dirname,'..', 'package.json')).version}`); if(!fs.existsSync(this.options.root)) { this.emit('debug', '[MCLC]: Attempting to create root folder'); @@ -49,12 +52,12 @@ class MCLCore extends EventEmitter { await this.handler.runInstaller(this.options.installer) } - const directory = override.directory || path.join(this.options.root, 'versions', this.options.version.number); + const directory = this.options.overrides.directory || path.join(this.options.root, 'versions', this.options.version.number); this.options.directory = directory; // Version JSON for the main launcher folder const versionFile = await this.handler.getVersion(); - const mcPath = override.minecraftJar || (this.options.version.custom ? path.join(this.options.root, 'versions', this.options.version.custom , `${this.options.version.custom}.jar`): + const mcPath = this.options.overrides.minecraftJar || (this.options.version.custom ? path.join(this.options.root, 'versions', this.options.version.custom , `${this.options.version.custom}.jar`): path.join(directory, `${this.options.version.number}.jar`)); const nativePath = await this.handler.getNatives(); @@ -121,8 +124,8 @@ class MCLCore extends EventEmitter { const minecraft = child.spawn(this.options.javaPath ? this.options.javaPath : 'java', launchArguments, {cwd: this.options.overrides.cwd || this.options.root}); - minecraft.stdout.on('data', (data) => this.emit('data', data)); - minecraft.stderr.on('data', (data) => this.emit('data', data)); + minecraft.stdout.on('data', (data) => this.emit('data', data.toString('utf-8'))); + minecraft.stderr.on('data', (data) => this.emit('data', data.toString('utf-8'))); minecraft.on('close', (code) => this.emit('close', code)); return minecraft; diff --git a/package.json b/package.json index 7b2a0f9..ae74d49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minecraft-launcher-core", - "version": "3.8.0", + "version": "3.8.1", "description": "Lightweight module that downloads and runs Minecraft using javascript / NodeJS", "main": "index.js", "dependencies": {