From 8f172a41e6dd7773a3c2b735726bbd91149a44a5 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Sat, 30 Jun 2018 03:16:57 -0400 Subject: [PATCH] Documented new functions in processbuilder. Minor fixes. Recursive call now uses the proper parameter (.mods). Submodules are only parsed if the parent mod is enabled for launch. --- app/assets/js/processbuilder.js | 82 +++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 19 deletions(-) diff --git a/app/assets/js/processbuilder.js b/app/assets/js/processbuilder.js index 8a6c5e8..f7d7b4b 100644 --- a/app/assets/js/processbuilder.js +++ b/app/assets/js/processbuilder.js @@ -74,14 +74,46 @@ class ProcessBuilder { return child } + /** + * Determine if an optional mod is enabled from its configuration value. If the + * configuration value is null, the required object will be used to + * determine if it is enabled. + * + * A mod is enabled if: + * * The configuration is not null and one of the following: + * * The configuration is a boolean and true. + * * The configuration is an object and its 'value' property is true. + * * The configuration is null and one of the following: + * * The required object is null. + * * The required object's 'def' property is null or true. + * + * @param {Object | boolean} modCfg The mod configuration object. + * @param {Object} required Optional. The required object from the mod's distro declaration. + * @returns {boolean} True if the mod is enabled, false otherwise. + */ 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 } + /** + * Determine if a mod is optional. + * + * A mod is optional if its required object is not null and its 'value' + * property is false. + * + * @param {Object} mdl The mod distro module. + * @returns {boolean} True if the mod is optional, otherwise false. + */ static isModOptional(mdl){ - mdl.required != null && mdl.required.value != null && mdl.required.value === false + return mdl.required != null && mdl.required.value != null && mdl.required.value === false } + /** + * Function which performs a preliminary scan of the top level + * mods. If liteloader is present here, we setup the special liteloader + * launch options. Note that liteloader is only allowed as a top level + * mod. It must not be declared as a submodule. + */ setupLiteLoader(){ const mdls = this.server.modules for(let i=0; i} mdls An array of modules to parse. + * @returns {{fMods: Array., lMods: Array.}} An object which contains + * a list of enabled forge mods and litemods. + */ resolveModConfiguration(modCfg, mdls){ let fMods = [] let lMods = [] @@ -108,23 +149,17 @@ class ProcessBuilder { for(let i=0; i} mods An array of mods to add to the mod list. + * @param {boolean} save Optional. Whether or not we should save the mod list file. + */ constructModList(type, mods, save = false){ const modList = { repositoryRoot: path.join(this.commonDir, 'modstore') } const ids = [] - for(let i=0; i