diff --git a/README.md b/README.md index 5c84ec9..d97a187 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,8 @@ launcher.authenticator.getAuth("email", "password").then(auth => { | `options.proxy.password` | String | Password for the proxy. | False | ##### Note -If you are loading up a client outside of vanilla Minecraft and Forge (Optifine for an example), you'll need to download the needed files yourself. +If you are loading up a client outside of vanilla Minecraft or Forge (Optifine and for an example), you'll need to download the needed files yourself +if you don't provide downloads url downloads like Forge and Fabric. Still need to provide the version jar. #### launcher.authenticator Functions diff --git a/components/handler.js b/components/handler.js index f23ea1f..9e036ee 100644 --- a/components/handler.js +++ b/components/handler.js @@ -246,14 +246,20 @@ module.exports.getClasses = function (options, version) { if(options.version.custom) { const customJarJson = require(path.join(options.root, 'versions', options.version.custom, `${options.version.custom}.json`)); - customJarJson.libraries.map(library => { + await Promise.all(customJarJson.libraries.map(async library => { const lib = library.name.split(':'); const jarPath = path.join(options.root, 'libraries', `${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}`); const name = `${lib[1]}-${lib[2]}.jar`; + if(!fs.existsSync(path.join(jarPath, name))) { + if(library.url) { + const url = `${library.url}${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}/${lib[1]}-${lib[2]}.jar`; + await downloadAsync(url, jarPath, name); + } + } libs.push(`${jarPath}/${name}`); - }) + })); } await Promise.all(version.libraries.map(async (_lib) => { diff --git a/components/launcher.js b/components/launcher.js index e827c08..6a5aa33 100644 --- a/components/launcher.js +++ b/components/launcher.js @@ -65,8 +65,9 @@ module.exports = async function (options) { classPaths.push(`${options.forge.path || options.forge}${separator}${forge.paths.join(separator)}${separator}${classes.join(separator)};${mcPath}`); classPaths.push(forge.forge.mainClass) } else { + const file = custom || versionFile; classPaths.push(`${mcPath}${separator}${classes.join(separator)}`); - classPaths.push(versionFile.mainClass || custom.mainClass); + classPaths.push(file.mainClass); } classPaths = await handler.cleanUp(classPaths); diff --git a/package.json b/package.json index 45411cc..058ffd5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minecraft-launcher-core", - "version": "2.7.0", + "version": "2.8.0", "description": "Module that downloads Minecraft assets and runs Minecraft. Also Supports Forge", "main": "index.js", "dependencies": {