Progress checkin, mostly works.
This commit is contained in:
parent
a22bd32cb1
commit
b32857e7de
@ -1661,43 +1661,6 @@ class AssetGuard extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// _enqueueMojangJRE(dir){
|
|
||||||
// return new Promise((resolve, reject) => {
|
|
||||||
// // Mojang does not host the JRE for linux.
|
|
||||||
// if(process.platform === 'linux'){
|
|
||||||
// resolve(false)
|
|
||||||
// }
|
|
||||||
// AssetGuard.loadMojangLauncherData().then(data => {
|
|
||||||
// if(data != null) {
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// const mJRE = data[Library.mojangFriendlyOS()]['64'].jre
|
|
||||||
// const url = mJRE.url
|
|
||||||
|
|
||||||
// request.head(url, (err, resp, body) => {
|
|
||||||
// if(err){
|
|
||||||
// resolve(false)
|
|
||||||
// } else {
|
|
||||||
// const name = url.substring(url.lastIndexOf('/')+1)
|
|
||||||
// const fDir = path.join(dir, name)
|
|
||||||
// const jre = new Asset('jre' + mJRE.version, mJRE.sha1, resp.headers['content-length'], url, fDir)
|
|
||||||
// this.java = new DLTracker([jre], jre.size, a => {
|
|
||||||
// fs.readFile(a.to, (err, data) => {
|
|
||||||
// // Data buffer needs to be decompressed from lzma,
|
|
||||||
// // not really possible using node.js
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// } catch (err){
|
|
||||||
// resolve(false)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
@ -1911,7 +1874,6 @@ class AssetGuard extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Util,
|
|
||||||
AssetGuard,
|
AssetGuard,
|
||||||
JavaGuard,
|
JavaGuard,
|
||||||
Asset,
|
Asset,
|
||||||
|
@ -7,7 +7,6 @@ const { getMojangOS, isLibraryCompatible, mcVersionAtLeast } = require('helios-
|
|||||||
const { Type } = require('helios-distribution-types')
|
const { Type } = require('helios-distribution-types')
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const { URL } = require('url')
|
|
||||||
|
|
||||||
const ConfigManager = require('./configmanager')
|
const ConfigManager = require('./configmanager')
|
||||||
|
|
||||||
@ -16,7 +15,7 @@ const logger = LoggerUtil.getLogger('ProcessBuilder')
|
|||||||
class ProcessBuilder {
|
class ProcessBuilder {
|
||||||
|
|
||||||
constructor(distroServer, versionData, forgeData, authUser, launcherVersion){
|
constructor(distroServer, versionData, forgeData, authUser, launcherVersion){
|
||||||
this.gameDir = path.join(ConfigManager.getInstanceDirectory(), distroServer.getID())
|
this.gameDir = path.join(ConfigManager.getInstanceDirectory(), distroServer.rawServer.id)
|
||||||
this.commonDir = ConfigManager.getCommonDirectory()
|
this.commonDir = ConfigManager.getCommonDirectory()
|
||||||
this.server = distroServer
|
this.server = distroServer
|
||||||
this.versionData = versionData
|
this.versionData = versionData
|
||||||
@ -41,10 +40,10 @@ class ProcessBuilder {
|
|||||||
process.throwDeprecation = true
|
process.throwDeprecation = true
|
||||||
this.setupLiteLoader()
|
this.setupLiteLoader()
|
||||||
logger.info('Using liteloader:', this.usingLiteLoader)
|
logger.info('Using liteloader:', this.usingLiteLoader)
|
||||||
const modObj = this.resolveModConfiguration(ConfigManager.getModConfiguration(this.server.getID()).mods, this.server.getModules())
|
const modObj = this.resolveModConfiguration(ConfigManager.getModConfiguration(this.server.rawServer.id).mods, this.server.modules)
|
||||||
|
|
||||||
// Mod list below 1.13
|
// Mod list below 1.13
|
||||||
if(!mcVersionAtLeast('1.13', this.server.getMinecraftVersion())){
|
if(!mcVersionAtLeast('1.13', this.server.rawServer.minecraftVersion)){
|
||||||
this.constructJSONModList('forge', modObj.fMods, true)
|
this.constructJSONModList('forge', modObj.fMods, true)
|
||||||
if(this.usingLiteLoader){
|
if(this.usingLiteLoader){
|
||||||
this.constructJSONModList('liteloader', modObj.lMods, true)
|
this.constructJSONModList('liteloader', modObj.lMods, true)
|
||||||
@ -54,14 +53,14 @@ class ProcessBuilder {
|
|||||||
const uberModArr = modObj.fMods.concat(modObj.lMods)
|
const uberModArr = modObj.fMods.concat(modObj.lMods)
|
||||||
let args = this.constructJVMArguments(uberModArr, tempNativePath)
|
let args = this.constructJVMArguments(uberModArr, tempNativePath)
|
||||||
|
|
||||||
if(mcVersionAtLeast('1.13', this.server.getMinecraftVersion())){
|
if(mcVersionAtLeast('1.13', this.server.rawServer.minecraftVersion)){
|
||||||
//args = args.concat(this.constructModArguments(modObj.fMods))
|
//args = args.concat(this.constructModArguments(modObj.fMods))
|
||||||
args = args.concat(this.constructModList(modObj.fMods))
|
args = args.concat(this.constructModList(modObj.fMods))
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info('Launch Arguments:', args)
|
logger.info('Launch Arguments:', args)
|
||||||
|
|
||||||
const child = child_process.spawn(ConfigManager.getJavaExecutable(this.server.getID()), args, {
|
const child = child_process.spawn(ConfigManager.getJavaExecutable(this.server.rawServer.id), args, {
|
||||||
cwd: this.gameDir,
|
cwd: this.gameDir,
|
||||||
detached: ConfigManager.getLaunchDetached()
|
detached: ConfigManager.getLaunchDetached()
|
||||||
})
|
})
|
||||||
@ -137,15 +136,15 @@ class ProcessBuilder {
|
|||||||
if(!ll.getRequired().value){
|
if(!ll.getRequired().value){
|
||||||
const modCfg = ConfigManager.getModConfiguration(this.server.rawServer.id).mods
|
const modCfg = ConfigManager.getModConfiguration(this.server.rawServer.id).mods
|
||||||
if(ProcessBuilder.isModEnabled(modCfg[ll.getVersionlessMavenIdentifier()], ll.getRequired())){
|
if(ProcessBuilder.isModEnabled(modCfg[ll.getVersionlessMavenIdentifier()], ll.getRequired())){
|
||||||
if(fs.existsSync(ll.localPath)){
|
if(fs.existsSync(ll.getPath())){
|
||||||
this.usingLiteLoader = true
|
this.usingLiteLoader = true
|
||||||
this.llPath = ll.localPath
|
this.llPath = ll.getPath()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(fs.existsSync(ll.localPath)){
|
if(fs.existsSync(ll.getPath())){
|
||||||
this.usingLiteLoader = true
|
this.usingLiteLoader = true
|
||||||
this.llPath = ll.localPath
|
this.llPath = ll.getPath()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,14 +306,11 @@ class ProcessBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_processAutoConnectArg(args){
|
_processAutoConnectArg(args){
|
||||||
if(ConfigManager.getAutoConnect() && this.server.isAutoConnect()){
|
if(ConfigManager.getAutoConnect() && this.server.rawServer.autoconnect){
|
||||||
const serverURL = new URL('my://' + this.server.getAddress())
|
|
||||||
args.push('--server')
|
args.push('--server')
|
||||||
args.push(serverURL.hostname)
|
args.push(this.server.hostname)
|
||||||
if(serverURL.port){
|
|
||||||
args.push('--port')
|
args.push('--port')
|
||||||
args.push(serverURL.port)
|
args.push(this.server.port)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +322,7 @@ class ProcessBuilder {
|
|||||||
* @returns {Array.<string>} An array containing the full JVM arguments for this process.
|
* @returns {Array.<string>} An array containing the full JVM arguments for this process.
|
||||||
*/
|
*/
|
||||||
constructJVMArguments(mods, tempNativePath){
|
constructJVMArguments(mods, tempNativePath){
|
||||||
if(mcVersionAtLeast('1.13', this.server.getMinecraftVersion())){
|
if(mcVersionAtLeast('1.13', this.server.rawServer.minecraftVersion)){
|
||||||
return this._constructJVMArguments113(mods, tempNativePath)
|
return this._constructJVMArguments113(mods, tempNativePath)
|
||||||
} else {
|
} else {
|
||||||
return this._constructJVMArguments112(mods, tempNativePath)
|
return this._constructJVMArguments112(mods, tempNativePath)
|
||||||
@ -354,9 +350,9 @@ class ProcessBuilder {
|
|||||||
args.push('-Xdock:name=HeliosLauncher')
|
args.push('-Xdock:name=HeliosLauncher')
|
||||||
args.push('-Xdock:icon=' + path.join(__dirname, '..', 'images', 'minecraft.icns'))
|
args.push('-Xdock:icon=' + path.join(__dirname, '..', 'images', 'minecraft.icns'))
|
||||||
}
|
}
|
||||||
args.push('-Xmx' + ConfigManager.getMaxRAM(this.server.getID()))
|
args.push('-Xmx' + ConfigManager.getMaxRAM(this.server.rawServer.id))
|
||||||
args.push('-Xms' + ConfigManager.getMinRAM(this.server.getID()))
|
args.push('-Xms' + ConfigManager.getMinRAM(this.server.rawServer.id))
|
||||||
args = args.concat(ConfigManager.getJVMOptions(this.server.getID()))
|
args = args.concat(ConfigManager.getJVMOptions(this.server.rawServer.id))
|
||||||
args.push('-Djava.library.path=' + tempNativePath)
|
args.push('-Djava.library.path=' + tempNativePath)
|
||||||
|
|
||||||
// Main Java Class
|
// Main Java Class
|
||||||
@ -405,9 +401,9 @@ class ProcessBuilder {
|
|||||||
args.push('-Xdock:name=HeliosLauncher')
|
args.push('-Xdock:name=HeliosLauncher')
|
||||||
args.push('-Xdock:icon=' + path.join(__dirname, '..', 'images', 'minecraft.icns'))
|
args.push('-Xdock:icon=' + path.join(__dirname, '..', 'images', 'minecraft.icns'))
|
||||||
}
|
}
|
||||||
args.push('-Xmx' + ConfigManager.getMaxRAM(this.server.getID()))
|
args.push('-Xmx' + ConfigManager.getMaxRAM(this.server.rawServer.id))
|
||||||
args.push('-Xms' + ConfigManager.getMinRAM(this.server.getID()))
|
args.push('-Xms' + ConfigManager.getMinRAM(this.server.rawServer.id))
|
||||||
args = args.concat(ConfigManager.getJVMOptions(this.server.getID()))
|
args = args.concat(ConfigManager.getJVMOptions(this.server.rawServer.id))
|
||||||
|
|
||||||
// Main Java Class
|
// Main Java Class
|
||||||
args.push(this.forgeData.mainClass)
|
args.push(this.forgeData.mainClass)
|
||||||
@ -471,7 +467,7 @@ class ProcessBuilder {
|
|||||||
break
|
break
|
||||||
case 'version_name':
|
case 'version_name':
|
||||||
//val = versionData.id
|
//val = versionData.id
|
||||||
val = this.server.getID()
|
val = this.server.rawServer.id
|
||||||
break
|
break
|
||||||
case 'game_directory':
|
case 'game_directory':
|
||||||
val = this.gameDir
|
val = this.gameDir
|
||||||
@ -569,7 +565,7 @@ class ProcessBuilder {
|
|||||||
break
|
break
|
||||||
case 'version_name':
|
case 'version_name':
|
||||||
//val = versionData.id
|
//val = versionData.id
|
||||||
val = this.server.getID()
|
val = this.server.rawServer.id
|
||||||
break
|
break
|
||||||
case 'game_directory':
|
case 'game_directory':
|
||||||
val = this.gameDir
|
val = this.gameDir
|
||||||
@ -668,7 +664,7 @@ class ProcessBuilder {
|
|||||||
classpathArg(mods, tempNativePath){
|
classpathArg(mods, tempNativePath){
|
||||||
let cpArgs = []
|
let cpArgs = []
|
||||||
|
|
||||||
if(!mcVersionAtLeast('1.17', this.server.getMinecraftVersion())) {
|
if(!mcVersionAtLeast('1.17', this.server.rawServer.minecraftVersion)) {
|
||||||
// Add the version.jar to the classpath.
|
// Add the version.jar to the classpath.
|
||||||
// Must not be added to the classpath for Forge 1.17+.
|
// Must not be added to the classpath for Forge 1.17+.
|
||||||
const version = this.versionData.id
|
const version = this.versionData.id
|
||||||
@ -826,15 +822,15 @@ class ProcessBuilder {
|
|||||||
* @returns {{[id: string]: string}} An object containing the paths of each library this server requires.
|
* @returns {{[id: string]: string}} An object containing the paths of each library this server requires.
|
||||||
*/
|
*/
|
||||||
_resolveServerLibraries(mods){
|
_resolveServerLibraries(mods){
|
||||||
const mdls = this.server.getModules()
|
const mdls = this.server.modules
|
||||||
let libs = {}
|
let libs = {}
|
||||||
|
|
||||||
// Locate Forge/Libraries
|
// Locate Forge/Libraries
|
||||||
for(let mdl of mdls){
|
for(let mdl of mdls){
|
||||||
const type = mdl.getType()
|
const type = mdl.rawModule.type
|
||||||
if(type === Type.ForgeHosted || type === Type.Library){
|
if(type === Type.ForgeHosted || type === Type.Library){
|
||||||
libs[mdl.getVersionlessID()] = mdl.getArtifact().getPath()
|
libs[mdl.getVersionlessMavenIdentifier()] = mdl.getPath()
|
||||||
if(mdl.hasSubModules()){
|
if(mdl.subModules.length > 0){
|
||||||
const res = this._resolveModuleLibraries(mdl)
|
const res = this._resolveModuleLibraries(mdl)
|
||||||
if(res.length > 0){
|
if(res.length > 0){
|
||||||
libs = {...libs, ...res}
|
libs = {...libs, ...res}
|
||||||
@ -863,20 +859,20 @@ class ProcessBuilder {
|
|||||||
* @returns {Array.<string>} An array containing the paths of each library this module requires.
|
* @returns {Array.<string>} An array containing the paths of each library this module requires.
|
||||||
*/
|
*/
|
||||||
_resolveModuleLibraries(mdl){
|
_resolveModuleLibraries(mdl){
|
||||||
if(!mdl.hasSubModules()){
|
if(!mdl.subModules.length > 0){
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
let libs = []
|
let libs = []
|
||||||
for(let sm of mdl.getSubModules()){
|
for(let sm of mdl.subModules){
|
||||||
if(sm.getType() === Type.Library){
|
if(sm.rawModule.type === Type.Library){
|
||||||
|
|
||||||
if(sm.getClasspath()) {
|
if(sm.rawModule.classpath ?? true) {
|
||||||
libs.push(sm.getArtifact().getPath())
|
libs.push(sm.getPath())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If this module has submodules, we need to resolve the libraries for those.
|
// If this module has submodules, we need to resolve the libraries for those.
|
||||||
// To avoid unnecessary recursive calls, base case is checked here.
|
// To avoid unnecessary recursive calls, base case is checked here.
|
||||||
if(mdl.hasSubModules()){
|
if(mdl.subModules.length > 0){
|
||||||
const res = this._resolveModuleLibraries(sm)
|
const res = this._resolveModuleLibraries(sm)
|
||||||
if(res.length > 0){
|
if(res.length > 0){
|
||||||
libs = libs.concat(res)
|
libs = libs.concat(res)
|
||||||
|
@ -5,13 +5,24 @@
|
|||||||
const cp = require('child_process')
|
const cp = require('child_process')
|
||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
const { URL } = require('url')
|
const { URL } = require('url')
|
||||||
const { MojangRestAPI, getServerStatus } = require('helios-core/mojang')
|
const {
|
||||||
|
MojangRestAPI,
|
||||||
|
getServerStatus
|
||||||
|
} = require('helios-core/mojang')
|
||||||
|
const {
|
||||||
|
RestResponseStatus,
|
||||||
|
isDisplayableError,
|
||||||
|
mcVersionAtLeast
|
||||||
|
} = require('helios-core/common')
|
||||||
|
const {
|
||||||
|
FullRepair,
|
||||||
|
DistributionIndexProcessor,
|
||||||
|
MojangIndexProcessor
|
||||||
|
} = require('helios-core/dl')
|
||||||
|
|
||||||
// Internal Requirements
|
// Internal Requirements
|
||||||
const DiscordWrapper = require('./assets/js/discordwrapper')
|
const DiscordWrapper = require('./assets/js/discordwrapper')
|
||||||
const ProcessBuilder = require('./assets/js/processbuilder')
|
const ProcessBuilder = require('./assets/js/processbuilder')
|
||||||
const { RestResponseStatus, isDisplayableError, mcVersionAtLeast } = require('helios-core/common')
|
|
||||||
const { stdout } = require('process')
|
|
||||||
|
|
||||||
// Launch Elements
|
// Launch Elements
|
||||||
const launch_content = document.getElementById('launch_content')
|
const launch_content = document.getElementById('launch_content')
|
||||||
@ -53,26 +64,22 @@ function setLaunchDetails(details){
|
|||||||
/**
|
/**
|
||||||
* Set the value of the loading progress bar and display that value.
|
* Set the value of the loading progress bar and display that value.
|
||||||
*
|
*
|
||||||
* @param {number} value The progress value.
|
* @param {number} percent Percentage (0-100)
|
||||||
* @param {number} max The total size.
|
|
||||||
* @param {number|string} percent Optional. The percentage to display on the progress label.
|
|
||||||
*/
|
*/
|
||||||
function setLaunchPercentage(value, max, percent = ((value/max)*100)){
|
function setLaunchPercentage(percent){
|
||||||
launch_progress.setAttribute('max', max)
|
launch_progress.setAttribute('max', 100)
|
||||||
launch_progress.setAttribute('value', value)
|
launch_progress.setAttribute('value', percent)
|
||||||
launch_progress_label.innerHTML = percent + '%'
|
launch_progress_label.innerHTML = percent + '%'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of the OS progress bar and display that on the UI.
|
* Set the value of the OS progress bar and display that on the UI.
|
||||||
*
|
*
|
||||||
* @param {number} value The progress value.
|
* @param {number} percent Percentage (0-100)
|
||||||
* @param {number} max The total download size.
|
|
||||||
* @param {number|string} percent Optional. The percentage to display on the progress label.
|
|
||||||
*/
|
*/
|
||||||
function setDownloadPercentage(value, max, percent = ((value/max)*100)){
|
function setDownloadPercentage(percent){
|
||||||
remote.getCurrentWindow().setProgressBar(value/max)
|
remote.getCurrentWindow().setProgressBar(percent/100)
|
||||||
setLaunchPercentage(value, max, percent)
|
setLaunchPercentage(percent)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,10 +105,10 @@ document.getElementById('launch_button').addEventListener('click', async (e) =>
|
|||||||
setLaunchPercentage(0, 100)
|
setLaunchPercentage(0, 100)
|
||||||
|
|
||||||
const jg = new JavaGuard(mcVersion)
|
const jg = new JavaGuard(mcVersion)
|
||||||
jg._validateJavaBinary(jExe).then((v) => {
|
jg._validateJavaBinary(jExe).then(async v => {
|
||||||
loggerLanding.info('Java version meta', v)
|
loggerLanding.info('Java version meta', v)
|
||||||
if(v.valid){
|
if(v.valid){
|
||||||
dlAsync()
|
await dlAsync()
|
||||||
} else {
|
} else {
|
||||||
asyncSystemScan(mcVersion)
|
asyncSystemScan(mcVersion)
|
||||||
}
|
}
|
||||||
@ -369,7 +376,7 @@ function asyncSystemScan(mcVersion, launchAfter = true){
|
|||||||
await populateJavaExecDetails(settingsJavaExecVal.value)
|
await populateJavaExecDetails(settingsJavaExecVal.value)
|
||||||
|
|
||||||
if(launchAfter){
|
if(launchAfter){
|
||||||
dlAsync()
|
await dlAsync()
|
||||||
}
|
}
|
||||||
sysAEx.disconnect()
|
sysAEx.disconnect()
|
||||||
}
|
}
|
||||||
@ -445,7 +452,7 @@ function asyncSystemScan(mcVersion, launchAfter = true){
|
|||||||
setLaunchDetails('Java Installed!')
|
setLaunchDetails('Java Installed!')
|
||||||
|
|
||||||
if(launchAfter){
|
if(launchAfter){
|
||||||
dlAsync()
|
await dlAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
sysAEx.disconnect()
|
sysAEx.disconnect()
|
||||||
@ -473,18 +480,28 @@ const GAME_JOINED_REGEX = /\[.+\]: Sound engine started/
|
|||||||
const GAME_LAUNCH_REGEX = /^\[.+\]: (?:MinecraftForge .+ Initialized|ModLauncher .+ starting: .+)$/
|
const GAME_LAUNCH_REGEX = /^\[.+\]: (?:MinecraftForge .+ Initialized|ModLauncher .+ starting: .+)$/
|
||||||
const MIN_LINGER = 5000
|
const MIN_LINGER = 5000
|
||||||
|
|
||||||
let aEx
|
async function dlAsync(login = true) {
|
||||||
let serv
|
|
||||||
let versionData
|
|
||||||
let forgeData
|
|
||||||
|
|
||||||
let progressListener
|
|
||||||
|
|
||||||
function dlAsync(login = true){
|
|
||||||
|
|
||||||
// Login parameter is temporary for debug purposes. Allows testing the validation/downloads without
|
// Login parameter is temporary for debug purposes. Allows testing the validation/downloads without
|
||||||
// launching the game.
|
// launching the game.
|
||||||
|
|
||||||
|
const loggerLaunchSuite = LoggerUtil.getLogger('LaunchSuite')
|
||||||
|
|
||||||
|
setLaunchDetails('Loading server information..')
|
||||||
|
|
||||||
|
let distro
|
||||||
|
|
||||||
|
try {
|
||||||
|
distro = await DistroAPI.refreshDistributionOrFallback()
|
||||||
|
onDistroRefresh(distro)
|
||||||
|
} catch(err) {
|
||||||
|
loggerLaunchSuite.error('Unable to refresh distribution index.', err)
|
||||||
|
showLaunchFailure('Fatal Error', 'Could not load a copy of the distribution index. See the console (CTRL + Shift + i) for more details.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const serv = distro.getServerById(ConfigManager.getSelectedServer())
|
||||||
|
|
||||||
if(login) {
|
if(login) {
|
||||||
if(ConfigManager.getSelectedAccount() == null){
|
if(ConfigManager.getSelectedAccount() == null){
|
||||||
loggerLanding.error('You must be logged into an account.')
|
loggerLanding.error('You must be logged into an account.')
|
||||||
@ -496,155 +513,65 @@ function dlAsync(login = true){
|
|||||||
toggleLaunchArea(true)
|
toggleLaunchArea(true)
|
||||||
setLaunchPercentage(0, 100)
|
setLaunchPercentage(0, 100)
|
||||||
|
|
||||||
const loggerLaunchSuite = LoggerUtil.getLogger('LaunchSuite')
|
const fullRepairModule = new FullRepair(
|
||||||
|
|
||||||
const forkEnv = JSON.parse(JSON.stringify(process.env))
|
|
||||||
forkEnv.CONFIG_DIRECT_PATH = ConfigManager.getLauncherDirectory()
|
|
||||||
|
|
||||||
// Start AssetExec to run validations and downloads in a forked process.
|
|
||||||
aEx = cp.fork(path.join(__dirname, 'assets', 'js', 'assetexec.js'), [
|
|
||||||
'AssetGuard',
|
|
||||||
ConfigManager.getCommonDirectory(),
|
ConfigManager.getCommonDirectory(),
|
||||||
ConfigManager.getJavaExecutable(ConfigManager.getSelectedServer())
|
ConfigManager.getLauncherDirectory(),
|
||||||
], {
|
ConfigManager.getSelectedServer(),
|
||||||
env: forkEnv,
|
DistroAPI.isDevMode()
|
||||||
stdio: 'pipe'
|
)
|
||||||
})
|
|
||||||
// Stdout
|
fullRepairModule.spawnReceiver()
|
||||||
aEx.stdio[1].setEncoding('utf8')
|
|
||||||
aEx.stdio[1].on('data', (data) => {
|
fullRepairModule.childProcess.on('error', (err) => {
|
||||||
console.log(`\x1b[32m[AEx]\x1b[0m ${data}`)
|
|
||||||
})
|
|
||||||
// Stderr
|
|
||||||
aEx.stdio[2].setEncoding('utf8')
|
|
||||||
aEx.stdio[2].on('data', (data) => {
|
|
||||||
console.log(`\x1b[31m[AEx]\x1b[0m ${data}`)
|
|
||||||
})
|
|
||||||
aEx.on('error', (err) => {
|
|
||||||
loggerLaunchSuite.error('Error during launch', err)
|
loggerLaunchSuite.error('Error during launch', err)
|
||||||
showLaunchFailure('Error During Launch', err.message || 'See console (CTRL + Shift + i) for more details.')
|
showLaunchFailure('Error During Launch', err.message || 'See console (CTRL + Shift + i) for more details.')
|
||||||
})
|
})
|
||||||
aEx.on('close', (code, signal) => {
|
fullRepairModule.childProcess.on('close', (code, _signal) => {
|
||||||
if(code !== 0){
|
if(code !== 0){
|
||||||
loggerLaunchSuite.error(`AssetExec exited with code ${code}, assuming error.`)
|
loggerLaunchSuite.error(`AssetExec exited with code ${code}, assuming error.`)
|
||||||
showLaunchFailure('Error During Launch', 'See console (CTRL + Shift + i) for more details.')
|
showLaunchFailure('Error During Launch', 'See console (CTRL + Shift + i) for more details.')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Establish communications between the AssetExec and current process.
|
loggerLaunchSuite.info('Validating files.')
|
||||||
aEx.on('message', async (m) => {
|
setLaunchDetails('Validating file integrity..')
|
||||||
|
const invalidFileCount = await fullRepairModule.verifyFiles(percent => {
|
||||||
|
setLaunchPercentage(percent)
|
||||||
|
})
|
||||||
|
setLaunchPercentage(100)
|
||||||
|
|
||||||
if(m.context === 'validate'){
|
if(invalidFileCount > 0) {
|
||||||
switch(m.data){
|
loggerLaunchSuite.info('Downloading files.')
|
||||||
case 'distribution':
|
|
||||||
setLaunchPercentage(20, 100)
|
|
||||||
loggerLaunchSuite.info('Validated distibution index.')
|
|
||||||
setLaunchDetails('Loading version information..')
|
|
||||||
break
|
|
||||||
case 'version':
|
|
||||||
setLaunchPercentage(40, 100)
|
|
||||||
loggerLaunchSuite.info('Version data loaded.')
|
|
||||||
setLaunchDetails('Validating asset integrity..')
|
|
||||||
break
|
|
||||||
case 'assets':
|
|
||||||
setLaunchPercentage(60, 100)
|
|
||||||
loggerLaunchSuite.info('Asset Validation Complete')
|
|
||||||
setLaunchDetails('Validating library integrity..')
|
|
||||||
break
|
|
||||||
case 'libraries':
|
|
||||||
setLaunchPercentage(80, 100)
|
|
||||||
loggerLaunchSuite.info('Library validation complete.')
|
|
||||||
setLaunchDetails('Validating miscellaneous file integrity..')
|
|
||||||
break
|
|
||||||
case 'files':
|
|
||||||
setLaunchPercentage(100, 100)
|
|
||||||
loggerLaunchSuite.info('File validation complete.')
|
|
||||||
setLaunchDetails('Downloading files..')
|
setLaunchDetails('Downloading files..')
|
||||||
break
|
await fullRepairModule.download(percent => {
|
||||||
}
|
setDownloadPercentage(percent)
|
||||||
} else if(m.context === 'progress'){
|
})
|
||||||
switch(m.data){
|
setDownloadPercentage(100)
|
||||||
case 'assets': {
|
|
||||||
const perc = (m.value/m.total)*20
|
|
||||||
setLaunchPercentage(40+perc, 100, parseInt(40+perc))
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'download':
|
|
||||||
setDownloadPercentage(m.value, m.total, m.percent)
|
|
||||||
break
|
|
||||||
case 'extract': {
|
|
||||||
// Show installing progress bar.
|
|
||||||
remote.getCurrentWindow().setProgressBar(2)
|
|
||||||
|
|
||||||
// Download done, extracting.
|
|
||||||
const eLStr = 'Extracting libraries'
|
|
||||||
let dotStr = ''
|
|
||||||
setLaunchDetails(eLStr)
|
|
||||||
progressListener = setInterval(() => {
|
|
||||||
if(dotStr.length >= 3){
|
|
||||||
dotStr = ''
|
|
||||||
} else {
|
} else {
|
||||||
dotStr += '.'
|
loggerLaunchSuite.info('No invalid files, skipping download.')
|
||||||
}
|
}
|
||||||
setLaunchDetails(eLStr + dotStr)
|
|
||||||
}, 750)
|
// Remove download bar.
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(m.context === 'complete'){
|
|
||||||
switch(m.data){
|
|
||||||
case 'download':
|
|
||||||
// Download and extraction complete, remove the loading from the OS progress bar.
|
|
||||||
remote.getCurrentWindow().setProgressBar(-1)
|
remote.getCurrentWindow().setProgressBar(-1)
|
||||||
if(progressListener != null){
|
|
||||||
clearInterval(progressListener)
|
fullRepairModule.destroyReceiver()
|
||||||
progressListener = null
|
|
||||||
}
|
|
||||||
|
|
||||||
setLaunchDetails('Preparing to launch..')
|
setLaunchDetails('Preparing to launch..')
|
||||||
break
|
|
||||||
}
|
|
||||||
} else if(m.context === 'error'){
|
|
||||||
switch(m.data){
|
|
||||||
case 'download':
|
|
||||||
loggerLaunchSuite.error('Error while downloading:', m.error)
|
|
||||||
|
|
||||||
if(m.error.code === 'ENOENT'){
|
const mojangIndexProcessor = new MojangIndexProcessor(
|
||||||
showLaunchFailure(
|
ConfigManager.getCommonDirectory(),
|
||||||
'Download Error',
|
serv.rawServer.minecraftVersion)
|
||||||
'Could not connect to the file server. Ensure that you are connected to the internet and try again.'
|
const distributionIndexProcessor = new DistributionIndexProcessor(
|
||||||
|
ConfigManager.getCommonDirectory(),
|
||||||
|
distro,
|
||||||
|
serv.rawServer.id
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
showLaunchFailure(
|
|
||||||
'Download Error',
|
|
||||||
'Check the console (CTRL + Shift + i) for more details. Please try again.'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
remote.getCurrentWindow().setProgressBar(-1)
|
// TODO need to load these.
|
||||||
|
const forgeData = await distributionIndexProcessor.loadForgeVersionJson(serv)
|
||||||
|
const versionData = await mojangIndexProcessor.getVersionJson()
|
||||||
|
|
||||||
// Disconnect from AssetExec
|
if(login) {
|
||||||
aEx.disconnect()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
} else if(m.context === 'validateEverything'){
|
|
||||||
|
|
||||||
let allGood = true
|
|
||||||
|
|
||||||
// If these properties are not defined it's likely an error.
|
|
||||||
if(m.result.forgeData == null || m.result.versionData == null){
|
|
||||||
loggerLaunchSuite.error('Error during validation:', m.result)
|
|
||||||
|
|
||||||
loggerLaunchSuite.error('Error during launch', m.result.error)
|
|
||||||
showLaunchFailure('Error During Launch', 'Please check the console (CTRL + Shift + i) for more details.')
|
|
||||||
|
|
||||||
allGood = false
|
|
||||||
}
|
|
||||||
|
|
||||||
forgeData = m.result.forgeData
|
|
||||||
versionData = m.result.versionData
|
|
||||||
|
|
||||||
if(login && allGood) {
|
|
||||||
const authUser = ConfigManager.getSelectedAccount()
|
const authUser = ConfigManager.getSelectedAccount()
|
||||||
loggerLaunchSuite.info(`Sending selected account (${authUser.displayName}) to ProcessBuilder.`)
|
loggerLaunchSuite.info(`Sending selected account (${authUser.displayName}) to ProcessBuilder.`)
|
||||||
let pb = new ProcessBuilder(serv, versionData, forgeData, authUser, remote.app.getVersion())
|
let pb = new ProcessBuilder(serv, versionData, forgeData, authUser, remote.app.getVersion())
|
||||||
@ -708,7 +635,6 @@ function dlAsync(login = true){
|
|||||||
setLaunchDetails('Done. Enjoy the server!')
|
setLaunchDetails('Done. Enjoy the server!')
|
||||||
|
|
||||||
// Init Discord Hook
|
// Init Discord Hook
|
||||||
const distro = await DistroAPI.getDistribution()
|
|
||||||
if(distro.rawDistribution.discord != null && serv.rawServerdiscord != null){
|
if(distro.rawDistribution.discord != null && serv.rawServerdiscord != null){
|
||||||
DiscordWrapper.initRPC(distro.rawDistribution.discord, serv.rawServer.discord)
|
DiscordWrapper.initRPC(distro.rawDistribution.discord, serv.rawServer.discord)
|
||||||
hasRPC = true
|
hasRPC = true
|
||||||
@ -728,30 +654,6 @@ function dlAsync(login = true){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disconnect from AssetExec
|
|
||||||
aEx.disconnect()
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Begin Validations
|
|
||||||
|
|
||||||
// Validate Forge files.
|
|
||||||
setLaunchDetails('Loading server information..')
|
|
||||||
|
|
||||||
DistroAPI.refreshDistributionOrFallback()
|
|
||||||
.then(data => {
|
|
||||||
onDistroRefresh(data)
|
|
||||||
serv = data.getServerById(ConfigManager.getSelectedServer())
|
|
||||||
aEx.send({task: 'execute', function: 'validateEverything', argsArr: [ConfigManager.getSelectedServer(), DistroAPI.isDevMode()]})
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
loggerLaunchSuite.error('Unable to refresh distribution index.', err)
|
|
||||||
showLaunchFailure('Fatal Error', 'Could not load a copy of the distribution index. See the console (CTRL + Shift + i) for more details.')
|
|
||||||
|
|
||||||
// Disconnect from AssetExec
|
|
||||||
aEx.disconnect()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user