From 247f63d64d9b30ac7c8b46432cbe7c01a2a78bba Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Sun, 21 May 2017 01:06:01 -0400 Subject: [PATCH] Starting work on forge downloads --- app/assets/js/assetguard.js | 78 ++++++++++++++++++++++++++++++----- app/assets/js/script.js | 12 ++++-- app/assets/westeroscraft.json | 14 +++---- 3 files changed, 84 insertions(+), 20 deletions(-) diff --git a/app/assets/js/assetguard.js b/app/assets/js/assetguard.js index 96730663..37ab351e 100644 --- a/app/assets/js/assetguard.js +++ b/app/assets/js/assetguard.js @@ -160,16 +160,15 @@ const instance = new AssetGuard() /** * Resolve an artifact id into a path. For example, on windows - * net.minecraftforge:forge:1.11.2-13.20.0.2282 - * becomes + * 'net.minecraftforge:forge:1.11.2-13.20.0.2282', '.jar' becomes * net\minecraftforge\forge\1.11.2-13.20.0.2282\forge-1.11.2-13.20.0.2282.jar * * @param {String} artifact - the artifact id string. * @param {String} extension - the extension of the file at the resolved path. * @returns {String} - the resolved relative path from the artifact id. */ -function _resolvePath(artifact, extension){ - let ps = artifact.split(':') +function _resolvePath(artifactid, extension){ + let ps = artifactid.split(':') let cs = ps[0].split('.') cs.push(ps[1]) @@ -294,7 +293,6 @@ function _validateForgeJar(buf, checksums){ function _extractPackXZ(filePath){ return new Promise(function(fulfill, reject){ const libPath = path.join(__dirname, '..', 'libraries', 'java', 'PackXZExtract.jar') - console.log(libPath) const child = child_process.spawn('C:\\Program Files\\Java\\jre1.8.0_131\\bin\\javaw.exe', ['-jar', libPath, '-packxz', filePath]) child.stdout.on('data', (data) => { console.log('minecraft:', data.toString('utf8')) @@ -589,15 +587,74 @@ function validateLogConfig(versionData, basePath){ }) } -function validateForge(){ +function validateDistribution(serverpackid, basePath){ + return new Promise(function(fulfill, reject){ + let distroindex = _chainValidateDistributionIndex(basePath).then((value) => { + let servers = value.servers + let serv = null + for(let i=0; i { + fulfill(JSON.parse(data)) + }) + }) } - +function _parseDistroModules(modules, basePath, version){ + let alist = [] + let asize = 0; + for(let i=0; i} identifiers - optional. The identifiers to process and corresponding parallel async task limit. */ -function processDlQueues(identifiers = [{id:'assets', limit:20}, {id:'libraries', limit:5}, {id:'files', limit:5}]){ +function processDlQueues(identifiers = [{id:'assets', limit:20}, {id:'libraries', limit:5}, {id:'files', limit:5}, {id:'forge', limit:5}]){ this.progress = 0; let win = remote.getCurrentWindow() @@ -634,5 +691,6 @@ module.exports = { processDlQueues, instance, Asset, - Library + Library, + validateDistribution } \ No newline at end of file diff --git a/app/assets/js/script.js b/app/assets/js/script.js index 2e836c2f..a2df99b9 100644 --- a/app/assets/js/script.js +++ b/app/assets/js/script.js @@ -39,10 +39,13 @@ $(document).on('ready', function(){ /* Open web links in the user's default browser. */ $(document).on('click', 'a[href^="http"]', function(event) { event.preventDefault(); - //testdownloads() - shell.openExternal(this.href) + testdownloads() + //console.log(os.homedir()) + //shell.openExternal(this.href) }); + + testdownloads = async function(){ const lp = require(path.join(__dirname, 'assets', 'js', 'launchprocess.js')) const basePath = path.join(__dirname, '..', 'mcfiles') @@ -53,8 +56,10 @@ testdownloads = async function(){ console.log('libs done') await ag.validateMiscellaneous(versionData, basePath) console.log('files done') + await ag.validateDistribution('WesterosCraft-1.11.2', basePath) + console.log('forge stuff done') ag.instance.on('dlcomplete', function(){ - lp.launchMinecraft(versionData, basePath) + //lp.launchMinecraft(versionData, basePath) }) ag.processDlQueues() } @@ -78,6 +83,7 @@ document.addEventListener('keydown', function (e) { break case match[3]: if(at === 3) ++at + break case match[4]: if(at === 4) ++at break diff --git a/app/assets/westeroscraft.json b/app/assets/westeroscraft.json index 421216ae..2960736b 100644 --- a/app/assets/westeroscraft.json +++ b/app/assets/westeroscraft.json @@ -4,11 +4,11 @@ { "id": "WesterosCraft-1.11.2", "name": "WesterosCraft Production Client", - "news-feed": "http://www.westeroscraft.com/api/rss.php?preset_id=12700544", - "icon-url": "http://mc.westeroscraft.com/WesterosCraftLauncher/files/server-prod.png", + "news_feed": "http://www.westeroscraft.com/api/rss.php?preset_id=12700544", + "icon_url": "http://mc.westeroscraft.com/WesterosCraftLauncher/files/server-prod.png", "revision": "0.0.1", - "server-ip": "mc.westeroscraft.com:4444", - "mc-version": "1.11.2", + "server_ip": "mc.westeroscraft.com:4444", + "mc_version": "1.11.2", "autoconnect": true, "modules": [ { @@ -21,7 +21,7 @@ "extension": ".jar", "url": "http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.11.2-13.20.0.2282/forge-1.11.2-13.20.0.2282-universal.jar" }, - "sub-modules": [ + "sub_modules": [ { "id": "net.minecraft:launchwrapper:1.12", "name": "Mojang (LaunchWrapper)", @@ -210,7 +210,7 @@ } }, { - "id": "net.minecraftforge.MercuriusUpdater:1.11.2", + "id": "net.minecraftforge:MercuriusUpdater:1.11.2", "name": "MercuriusUpdater 1.11.2", "type": "library", "artifact": { @@ -289,7 +289,7 @@ "path": "mod_chatBubbles-1.0.1_for_1.11.2.litemod", "url": "http://mc.westeroscraft.com/WesterosCraftLauncher/files/1.11.2/mod_chatBubbles-1.0.1_for_1.11.2.litemod" }, - "sub-modules": [ + "sub_modules": [ { "id": "customRegexes", "name": "Custom Regexes for Chat Bubbles",