mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 19:52:14 -08:00
Compare commits
No commits in common. "3837588ecd989f534bc29b0933d37d1c4aa5000e" and "4636f7200ce46a37eff56aa460be589d4d8deffd" have entirely different histories.
3837588ecd
...
4636f7200c
@ -5,7 +5,7 @@
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2021,
|
||||
"ecmaVersion": 2019,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
|
@ -118,7 +118,7 @@ class Module {
|
||||
* @returns {Module} The parsed Module.
|
||||
*/
|
||||
static fromJSON(json, serverid){
|
||||
return new Module(json.id, json.name, json.type, json.classpath, json.required, json.artifact, json.subModules, serverid)
|
||||
return new Module(json.id, json.name, json.type, json.required, json.artifact, json.subModules, serverid)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,10 +143,9 @@ class Module {
|
||||
}
|
||||
}
|
||||
|
||||
constructor(id, name, type, classpath, required, artifact, subModules, serverid) {
|
||||
constructor(id, name, type, required, artifact, subModules, serverid) {
|
||||
this.identifier = id
|
||||
this.type = type
|
||||
this.classpath = classpath
|
||||
this._resolveMetaData()
|
||||
this.name = name
|
||||
this.required = Required.fromJSON(required)
|
||||
@ -307,13 +306,6 @@ class Module {
|
||||
return this.type
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean} Whether or not this library should be on the classpath.
|
||||
*/
|
||||
getClasspath(){
|
||||
return this.classpath ?? true
|
||||
}
|
||||
|
||||
}
|
||||
exports.Module
|
||||
|
||||
|
@ -709,7 +709,6 @@ class ProcessBuilder {
|
||||
* @returns {{[id: string]: string}} An object containing the paths of each library mojang declares.
|
||||
*/
|
||||
_resolveMojangLibraries(tempNativePath){
|
||||
const nativesRegex = /.+:natives-([^-]+)(?:-(.+))?/
|
||||
const libs = {}
|
||||
|
||||
const libArr = this.versionData.libraries
|
||||
@ -717,9 +716,13 @@ class ProcessBuilder {
|
||||
for(let i=0; i<libArr.length; i++){
|
||||
const lib = libArr[i]
|
||||
if(Library.validateRules(lib.rules, lib.natives)){
|
||||
|
||||
// Pre-1.19 has a natives object.
|
||||
if(lib.natives != null) {
|
||||
if(lib.natives == null){
|
||||
const dlInfo = lib.downloads
|
||||
const artifact = dlInfo.artifact
|
||||
const to = path.join(this.libPath, artifact.path)
|
||||
const versionIndependentId = lib.name.substring(0, lib.name.lastIndexOf(':'))
|
||||
libs[versionIndependentId] = to
|
||||
} else {
|
||||
// Extract the native library.
|
||||
const exclusionArr = lib.extract != null ? lib.extract.exclude : ['META-INF/']
|
||||
const artifact = lib.downloads.classifiers[lib.natives[Library.mojangFriendlyOS()].replace('${arch}', process.arch.replace('x', ''))]
|
||||
@ -754,65 +757,6 @@ class ProcessBuilder {
|
||||
|
||||
}
|
||||
}
|
||||
// 1.19+ logic
|
||||
else if(lib.name.includes('natives-')) {
|
||||
|
||||
const regexTest = nativesRegex.exec(lib.name)
|
||||
// const os = regexTest[1]
|
||||
const arch = regexTest[2] ?? 'x64'
|
||||
|
||||
if(arch != process.arch) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Extract the native library.
|
||||
const exclusionArr = lib.extract != null ? lib.extract.exclude : ['META-INF/', '.git', '.sha1']
|
||||
const artifact = lib.downloads.artifact
|
||||
|
||||
// Location of native zip.
|
||||
const to = path.join(this.libPath, artifact.path)
|
||||
|
||||
let zip = new AdmZip(to)
|
||||
let zipEntries = zip.getEntries()
|
||||
|
||||
// Unzip the native zip.
|
||||
for(let i=0; i<zipEntries.length; i++){
|
||||
if(zipEntries[i].isDirectory) {
|
||||
continue
|
||||
}
|
||||
|
||||
const fileName = zipEntries[i].entryName
|
||||
|
||||
let shouldExclude = false
|
||||
|
||||
// Exclude noted files.
|
||||
exclusionArr.forEach(function(exclusion){
|
||||
if(fileName.indexOf(exclusion) > -1){
|
||||
shouldExclude = true
|
||||
}
|
||||
})
|
||||
|
||||
const extractName = fileName.includes('/') ? fileName.substring(fileName.lastIndexOf('/')) : fileName
|
||||
|
||||
// Extract the file.
|
||||
if(!shouldExclude){
|
||||
fs.writeFile(path.join(tempNativePath, extractName), zipEntries[i].getData(), (err) => {
|
||||
if(err){
|
||||
logger.error('Error while extracting native library:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// No natives
|
||||
else {
|
||||
const dlInfo = lib.downloads
|
||||
const artifact = dlInfo.artifact
|
||||
const to = path.join(this.libPath, artifact.path)
|
||||
const versionIndependentId = lib.name.substring(0, lib.name.lastIndexOf(':'))
|
||||
libs[versionIndependentId] = to
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -872,9 +816,15 @@ class ProcessBuilder {
|
||||
for(let sm of mdl.getSubModules()){
|
||||
if(sm.getType() === DistroManager.Types.Library){
|
||||
|
||||
if(sm.getClasspath()) {
|
||||
libs.push(sm.getArtifact().getPath())
|
||||
// TODO Add as file or something.
|
||||
const x = sm.getIdentifier()
|
||||
console.log(x)
|
||||
if(x.includes(':universal') || x.includes(':slim') || x.includes(':extra') || x.includes(':srg') || x.includes(':client')) {
|
||||
console.log('SKIPPING ' + x)
|
||||
continue
|
||||
}
|
||||
|
||||
libs.push(sm.getArtifact().getPath())
|
||||
}
|
||||
// If this module has submodules, we need to resolve the libraries for those.
|
||||
// To avoid unnecessary recursive calls, base case is checked here.
|
||||
|
@ -138,8 +138,8 @@ function initSettingsValues(){
|
||||
if(v.type === 'number' || v.type === 'text'){
|
||||
// Special Conditions
|
||||
if(cVal === 'JavaExecutable'){
|
||||
v.value = gFn.apply(null, gFnOpts)
|
||||
populateJavaExecDetails(v.value)
|
||||
v.value = gFn.apply(null, gFnOpts)
|
||||
} else if (cVal === 'DataDirectory'){
|
||||
v.value = gFn.apply(null, gFnOpts)
|
||||
} else if(cVal === 'JVMOptions'){
|
||||
@ -1380,6 +1380,7 @@ function prepareJavaTab(){
|
||||
bindRangeSlider()
|
||||
populateMemoryStatus()
|
||||
populateJavaReqDesc()
|
||||
populateJavaExecDetails()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,12 +208,6 @@ The name of the module. Used on the UI.
|
||||
|
||||
The type of the module.
|
||||
|
||||
### `Module.classpath: boolean`
|
||||
|
||||
**OPTIONAL**
|
||||
|
||||
If the module is of type `Library`, whether the library should be added to the classpath. Defaults to true.
|
||||
|
||||
### `Module.required: Required`
|
||||
|
||||
**OPTIONAL**
|
||||
|
Loading…
Reference in New Issue
Block a user