diff --git a/README.md b/README.md index b925262..71bd047 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Minecraft Launcher Core ### Currently only supports MC 1.7.3 and up. -A script that launches Minecraft using NodeJS. -Supports Vanilla and Forge. +MCLC is a NodeJS solution for launching modded and vanilla Minecraft without having to download and format everything yourself. +Basically a core for your Electron or script based launchers. ### Installing @@ -10,7 +10,6 @@ Supports Vanilla and Forge. ### Usage - ##### launcher.core Options | Parameter | Type | Description | Required | @@ -49,14 +48,15 @@ Supports Vanilla and Forge. #### Events -| Event Name | Type | Description | -|-------------------|---------|-------------------------------------------------------------------------------------| -| `data` | Buffer | Emitted when information is returned from the Minecraft Process | -| `close` | Integer | Code number that is returned by the Minecraft Process | -| `error` | String | Emitted when the Minecraft Process errors | -| `package-extract` | null | Emitted when `clientPackage` finishes being extracted | +| Event Name | Type | Description | +|-------------------|---------|---------------------------------------------------------------------------------------| +| `data` | Buffer | Emitted when information is returned from the Minecraft Process | +| `close` | Integer | Code number that is returned by the Minecraft Process | +| `error` | String | Emitted when the Minecraft Process errors | +| `package-extract` | null | Emitted when `clientPackage` finishes being extracted | | `start` | null | Emitted after `launchArguments` are set. THIS WILL BE DEPRECATED AS ITS NOT ACCURATE | - +| `download` | String | Emitted when a file successfully downloads | +| `download-status` | Object | Emitted when data is received while downloading | #### Client Package Function Client Packages allow the client to run offline on setup. This function should be used outside the actual launcher. @@ -69,7 +69,6 @@ this function is in the `handler` component. | `versions` | Array | Array of the versions being downloaded and being made into a package. | True | | `os` | String | OS that the package will be loaded on. OS specific natives need this. | True | - ### Examples ```javascript const launcher = require('minecraft-launcher-core'); diff --git a/components/handler.js b/components/handler.js index f731160..a3ab515 100644 --- a/components/handler.js +++ b/components/handler.js @@ -25,8 +25,11 @@ function downloadAsync (url, directory, name) { }); _request.on('data', (data) => { + let size = 0; + if(fs.existsSync(path.join(directory, name))) size = fs.statSync(path.join(directory, name))["size"]; event.emit('download-status', { - "current": Math.round(fs.statSync(path.join(directory, name))["size"] / 10000), + "name": name, + "current": Math.round(size / 10000), "total": data.length }) }); @@ -35,7 +38,7 @@ function downloadAsync (url, directory, name) { _request.pipe(file); file.once('finish', function() { - console.log("Downloaded: " + name); + event.emit('download', name); resolve({failed: false, asset: null}); }); }); @@ -289,4 +292,4 @@ module.exports.extractPackage = function(root, clientPackage) { event.emit('package-extract', true); resolve(); }); -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index 8f907b7..92a84c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minecraft-launcher-core", - "version": "2.1.3", + "version": "2.2.0", "description": "Module that downloads Minecraft assets and runs Minecraft. Also Supports Forge", "main": "index.js", "dependencies": {