diff --git a/app/assets/js/assetguard.js b/app/assets/js/assetguard.js index dde64c3..df2cf04 100644 --- a/app/assets/js/assetguard.js +++ b/app/assets/js/assetguard.js @@ -1500,12 +1500,11 @@ class AssetGuard extends EventEmitter { switch(obType){ case 'forge-hosted': case 'forge': + case 'liteloader': case 'library': obPath = path.join(this.commonPath, 'libraries', obPath) break case 'forgemod': - obPath = path.join(this.commonPath, 'modstore', obPath) - break case 'litemod': obPath = path.join(this.commonPath, 'modstore', obPath) break diff --git a/app/assets/js/processbuilder.js b/app/assets/js/processbuilder.js index fe08bf9..8a6c5e8 100644 --- a/app/assets/js/processbuilder.js +++ b/app/assets/js/processbuilder.js @@ -19,8 +19,12 @@ class ProcessBuilder { this.versionData = versionData this.forgeData = forgeData this.authUser = authUser - this.fmlDir = path.join(this.commonDir, 'versions', this.server.id + '.json') + this.fmlDir = path.join(this.gameDir, 'forgeModList.json') + this.llDir = path.join(this.gameDir, 'liteloaderModList.json') this.libPath = path.join(this.commonDir, 'libraries') + + this.usingLiteLoader = false + this.llPath = null } /** @@ -30,9 +34,14 @@ class ProcessBuilder { mkpath.sync(this.gameDir) const tempNativePath = path.join(os.tmpdir(), ConfigManager.getTempNativeFolder(), crypto.pseudoRandomBytes(16).toString('hex')) process.throwDeprecation = true - const mods = this.resolveDefaultMods() - this.constructFMLModList(mods, true) - const args = this.constructJVMArguments(mods, tempNativePath) + this.setupLiteLoader() + const modObj = this.resolveModConfiguration(ConfigManager.getModConfiguration(this.server.id).mods, this.server.modules) + this.constructModList('forge', modObj.fMods, true) + if(this.usingLiteLoader){ + this.constructModList('liteloader', modObj.lMods, true) + } + const uberModArr = modObj.fMods.concat(modObj.lMods) + const args = this.constructJVMArguments(uberModArr, tempNativePath) console.log(args) @@ -65,41 +74,90 @@ class ProcessBuilder { return child } - resolveDefaultMods(options = {type: 'forgemod'}){ - //Returns array of default forge mods to load. - const mods = [] + static isModEnabled(modCfg, required = null){ + return modCfg != null ? ((typeof modCfg === 'boolean' && modCfg) || (typeof modCfg === 'object' && modCfg.value)) : required != null && required.def != null ? required.def : true + } + + static isModOptional(mdl){ + mdl.required != null && mdl.required.value != null && mdl.required.value === false + } + + setupLiteLoader(){ const mdls = this.server.modules - const modCfg = ConfigManager.getModConfiguration(this.server.id).mods - - for(let i=0; i 0){ + return { + value: origin.required != null && origin.required.def != null ? origin.required.def : true, + mods + } + } + } + return origin.required != null && origin.required.def != null ? origin.required.def : true +} + +/** + * Recursively merge an old configuration into a new configuration. + * + * @param {boolean | Object} o The old configuration value. + * @param {boolean | Object} n The new configuration value. + * + * @returns {boolean | Object} The merged configuration. + */ +function mergeModConfiguration(o, n){ + if(typeof o === 'boolean'){ + if(typeof n === 'boolean') return o + else if(typeof n === 'object'){ + n.value = o + return n + } + } else if(typeof o === 'object'){ + if(typeof n === 'boolean') return o.value + else if(typeof n === 'object'){ + n.value = o.value + + const newMods = Object.keys(n.mods) + for(let i=0; i