From 411c9fce3416978dd9ba4d5e882a5bf42aef375c Mon Sep 17 00:00:00 2001 From: TheFlash787 Date: Wed, 12 Aug 2020 23:50:21 +0100 Subject: [PATCH] Setup the server code in the configuration --- app/assets/js/configmanager.js | 25 ++++++++++++++++++++++--- app/assets/js/scripts/settings.js | 2 ++ app/settings.ejs | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/assets/js/configmanager.js b/app/assets/js/configmanager.js index 65a7306..b4157bc 100644 --- a/app/assets/js/configmanager.js +++ b/app/assets/js/configmanager.js @@ -23,7 +23,7 @@ exports.getLauncherDirectory = function(){ /** * Get the launcher's data directory. This is where all files related * to game launch are installed (common, instances, java, etc). - * + * * @returns {string} The absolute path of the launcher's data directory. */ exports.getDataDirectory = function(def = false){ @@ -32,13 +32,31 @@ exports.getDataDirectory = function(def = false){ /** * Set the new data directory. - * + * * @param {string} dataDirectory The new data directory. */ exports.setDataDirectory = function(dataDirectory){ config.settings.launcher.dataDirectory = dataDirectory } +/** + * Get the launcher's server code if set. This will be used to load hidden servers. + * + * @returns {string} The server code that has been put into the launcher + */ +exports.getServerCode = function(def = false){ + return !def ? config.settings.launcher.serverCode : DEFAULT_CONFIG.settings.launcher.serverCode +} + +/** + * Set the new server code + * + * @param {string} serverCode The new server code. + */ +exports.setServerCode = function(serverCode){ + config.settings.launcher.serverCode = serverCode +} + const configPath = path.join(exports.getLauncherDirectory(), 'config.json') const configPathLEGACY = path.join(dataPath, 'config.json') const firstLaunch = !fs.existsSync(configPath) && !fs.existsSync(configPathLEGACY) @@ -91,7 +109,8 @@ const DEFAULT_CONFIG = { }, launcher: { allowPrerelease: false, - dataDirectory: dataPath + dataDirectory: dataPath, + serverCode: null } }, newsCache: { diff --git a/app/assets/js/scripts/settings.js b/app/assets/js/scripts/settings.js index 23ef79c..75e0b4d 100644 --- a/app/assets/js/scripts/settings.js +++ b/app/assets/js/scripts/settings.js @@ -136,6 +136,8 @@ function initSettingsValues(){ v.value = gFn() } else if (cVal === 'DataDirectory'){ v.value = gFn() + } else if (cVal === 'ServerCode'){ + v.value = gFn() } else if(cVal === 'JVMOptions'){ v.value = gFn().join(' ') } else { diff --git a/app/settings.ejs b/app/settings.ejs index a0d10c5..1a98e41 100644 --- a/app/settings.ejs +++ b/app/settings.ejs @@ -270,7 +270,7 @@
Server Code
- +
Any server code here (if valid) will grant you access to certain modpacks or servers that are set up to use the code.