Ensure libs are properly added to classpath as .jar

This commit is contained in:
Daniel Scalzi 2020-03-08 21:10:43 -04:00
parent 5fc6be444a
commit 1a2e9f3be4
No known key found for this signature in database
GPG Key ID: D18EA3FB4B142A57

View File

@ -569,6 +569,24 @@ class ProcessBuilder {
return mcArgs
}
/**
* Ensure that the classpath entries all point to jar files.
*
* @param {Array.<String>} list Array of classpath entries.
*/
_processClassPathList(list) {
const ext = '.jar'
const extLen = ext.length
for(let i=0; i<list.length; i++) {
const extIndex = list[i].indexOf(ext)
if(extIndex > -1 && extIndex !== list[i].length - extLen) {
list[i] = list[i].substring(0, extIndex + extLen)
}
}
}
/**
* Resolve the full classpath argument list for this process. This method will resolve all Mojang-declared
* libraries as well as the libraries declared by the server. Since mods are permitted to declare libraries,
@ -601,6 +619,8 @@ class ProcessBuilder {
const finalLibs = {...mojangLibs, ...servLibs}
cpArgs = cpArgs.concat(Object.values(finalLibs))
this._processClassPathList(cpArgs)
return cpArgs
}
@ -733,6 +753,7 @@ class ProcessBuilder {
}
return libs
}
}
module.exports = ProcessBuilder