From aa0e1a20cad551532f68024d5e3af86fc371befb Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Sat, 23 Jun 2018 21:03:49 -0400 Subject: [PATCH] Added initial support of liteloader + optional submodules. Liteloader is loaded as a library, with special launch conditions being executed when it is enabled. Litemods are constructed into a mod list and passed to liteloader via the --modRepo argument. The launcher now supports optional submodules. These are parsed recursively, there is no depth limit. Typically the depth will be only 2 as litemods are optional submoduless of liteloader. --- app/assets/js/assetguard.js | 3 +- app/assets/js/processbuilder.js | 116 ++++++++++++++++++++++++------ app/assets/js/scripts/uibinder.js | 93 ++++++++++++++++++++---- app/assets/westeroscraft.json | 32 +++++++++ 4 files changed, 205 insertions(+), 39 deletions(-) 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