diff --git a/app/assets/js/processbuilder.js b/app/assets/js/processbuilder.js index b86698c4f5..5b30dfe839 100644 --- a/app/assets/js/processbuilder.js +++ b/app/assets/js/processbuilder.js @@ -836,6 +836,13 @@ class ProcessBuilder { libs = {...libs, ...res} } } + } else if(type === Type.Forge){ + // Forge installer generated libraries + const forgeLibs = [] + for (const library of this.forgeData.libraries) { + forgeLibs.push(path.join(ConfigManager.getCommonDirectory(), 'libraries', library.downloads.artifact.path)) + } + libs = {...libs, ...forgeLibs} } } diff --git a/app/assets/js/scripts/landing.js b/app/assets/js/scripts/landing.js index 94d311a095..55bd417ab4 100644 --- a/app/assets/js/scripts/landing.js +++ b/app/assets/js/scripts/landing.js @@ -5,6 +5,7 @@ const cp = require('child_process') const crypto = require('crypto') const { URL } = require('url') +const { join } = require('path') const { MojangRestAPI, getServerStatus @@ -552,6 +553,33 @@ async function dlAsync(login = true) { serv.rawServer.id ) + // Install Forge + let wrapperPath + if(isDev) { + wrapperPath = join(process.cwd(), 'libraries', 'java', 'ForgeInstallerCLI.jar') + } else { + const exePath = remote.app.getPath('exe') + if(process.platform === 'darwin'){ + wrapperPath = join(exePath, '..', '..', 'Resources', 'libraries', 'java', 'ForgeInstallerCLI.jar') + } else { + wrapperPath = join(exePath, '..', 'resources', 'libraries', 'java', 'ForgeInstallerCLI.jar') + } + } + + // Launch Forge Installer + loggerLaunchSuite.info('Installing Forge.') + setLaunchDetails('Installing Forge..') + setLaunchPercentage(0) + const jExe = ConfigManager.getJavaExecutable(ConfigManager.getSelectedServer()) + await distributionIndexProcessor.installForge(jExe, wrapperPath, percent => { + setDownloadPercentage(percent) + }) + setDownloadPercentage(100) + + // Remove download bar. + remote.getCurrentWindow().setProgressBar(-1) + + // After Forge installed, we can get the Forge version data. const forgeData = await distributionIndexProcessor.loadForgeVersionJson(serv) const versionData = await mojangIndexProcessor.getVersionJson() diff --git a/libraries/java/ForgeInstallerCLI.jar b/libraries/java/ForgeInstallerCLI.jar new file mode 100644 index 0000000000..759ca92747 Binary files /dev/null and b/libraries/java/ForgeInstallerCLI.jar differ