[HOTFIX & Slight Changes]

This commit is contained in:
Pierce 2020-06-19 12:26:58 -04:00
parent 9075bd0ea6
commit 0905b4154d
3 changed files with 29 additions and 23 deletions

View file

@ -95,9 +95,12 @@ class Handler {
checkSum (hash, file) { checkSum (hash, file) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
checksum.file(file, (err, sum) => { checksum.file(file, (err, sum) => {
err if (err) {
? reject(new Error(err)) this.client.emit('debug', `[MCLC]: Failed to check file hash due to ${err}`)
: resolve(hash === sum) resolve(false)
} else {
resolve(hash === sum)
}
}) })
}) })
} }
@ -107,8 +110,7 @@ class Handler {
const versionJsonPath = this.options.overrides.versionJson || path.join(this.options.directory, `${this.options.version.number}.json`) const versionJsonPath = this.options.overrides.versionJson || path.join(this.options.directory, `${this.options.version.number}.json`)
if (fs.existsSync(versionJsonPath)) { if (fs.existsSync(versionJsonPath)) {
this.version = JSON.parse(fs.readFileSync(versionJsonPath)) this.version = JSON.parse(fs.readFileSync(versionJsonPath))
resolve(this.version) return resolve(this.version)
return
} }
const manifest = `${this.options.overrides.url.meta}/mc/game/version_manifest.json` const manifest = `${this.options.overrides.url.meta}/mc/game/version_manifest.json`
@ -124,7 +126,7 @@ class Handler {
this.client.emit('debug', '[MCLC]: Parsed version from version manifest') this.client.emit('debug', '[MCLC]: Parsed version from version manifest')
this.version = JSON.parse(body) this.version = JSON.parse(body)
resolve(this.version) return resolve(this.version)
}) })
} }
} }
@ -370,10 +372,17 @@ class Handler {
const launchArgs = `"${this.options.javaPath ? this.options.javaPath : 'java'}" -jar ${path.resolve(this.options.forgeWrapper.jar)}` + const launchArgs = `"${this.options.javaPath ? this.options.javaPath : 'java'}" -jar ${path.resolve(this.options.forgeWrapper.jar)}` +
` --installer=${this.options.forge} --instance=${this.options.root} ` + ` --installer=${this.options.forge} --instance=${this.options.root} ` +
`--saveTo=${path.join(this.options.root, 'libraries', 'io', 'github', 'zekerzhayard', 'ForgeWrapper', this.options.forgeWrapper.version)}` `--saveTo=${path.join(this.options.root, 'libraries', 'io', 'github', 'zekerzhayard', 'ForgeWrapper', this.options.forgeWrapper.version)}`
const fw = child.exec(launchArgs) const fw = child.exec(launchArgs)
const forgeJson = path.join(this.options.root, 'forge', this.version.id, 'version.json')
fw.on('close', (e) => { fw.on('close', (e) => {
resolve(JSON.parse(fs.readFileSync(path.join(this.options.root, 'forge', this.version.id, 'version.json'), { encoding: 'utf8' }))) if (!fs.existsSync(forgeJson)) {
this.client.emit('debug', '[MCLC]: ForgeWrapper did not produce a version file, using Vanilla')
resolve(null)
} else {
resolve(JSON.parse(fs.readFileSync(forgeJson, { encoding: 'utf8' })))
}
}) })
}) })
} }
@ -548,17 +557,14 @@ class Handler {
} }
async extractPackage (options = this.options) { async extractPackage (options = this.options) {
return new Promise(async resolve => { if (options.clientPackage.startsWith('http')) {
if (options.clientPackage.startsWith('http')) { await this.downloadAsync(options.clientPackage, options.root, 'clientPackage.zip', true, 'client-package')
await this.downloadAsync(options.clientPackage, options.root, 'clientPackage.zip', true, 'client-package') options.clientPackage = path.join(options.root, 'clientPackage.zip')
options.clientPackage = path.join(options.root, 'clientPackage.zip') }
} new Zip(options.clientPackage).extractAllTo(options.root, true)
new Zip(options.clientPackage).extractAllTo(options.root, true) if (options.removePackage) shelljs.rm(options.clientPackage)
this.client.emit('package-extract', true)
if (options.removePackage) shelljs.rm(options.clientPackage)
resolve() return this.client.emit('package-extract', true)
})
} }
} }

View file

@ -5,7 +5,7 @@ const fs = require('fs')
const EventEmitter = require('events').EventEmitter const EventEmitter = require('events').EventEmitter
class MCLCore extends EventEmitter { class MCLCore extends EventEmitter {
async launch (options = this.options) { async launch (options) {
this.options = options this.options = options
this.options.root = path.resolve(this.options.root) this.options.root = path.resolve(this.options.root)
this.options.overrides = { this.options.overrides = {
@ -81,7 +81,7 @@ class MCLCore extends EventEmitter {
if (forge === false) custom = await this.handler.getForgedWrapped() if (forge === false) custom = await this.handler.getForgedWrapped()
} }
if (this.options.version.custom || custom) { if (this.options.version.custom || custom) {
this.emit('debug', '[MCLC]: Detected custom in options, setting custom version file') if (!custom) this.emit('debug', '[MCLC]: Detected custom in options, setting custom version file')
custom = custom || JSON.parse(fs.readFileSync(path.join(this.options.root, 'versions', this.options.version.custom, `${this.options.version.custom}.json`), { encoding: 'utf8' })) custom = custom || JSON.parse(fs.readFileSync(path.join(this.options.root, 'versions', this.options.version.custom, `${this.options.version.custom}.json`), { encoding: 'utf8' }))
} }
@ -93,9 +93,9 @@ class MCLCore extends EventEmitter {
'-XX:-OmitStackTraceInFastThrow', '-XX:-OmitStackTraceInFastThrow',
'-Dfml.ignorePatchDiscrepancies=true', '-Dfml.ignorePatchDiscrepancies=true',
'-Dfml.ignoreInvalidMinecraftCertificates=true', '-Dfml.ignoreInvalidMinecraftCertificates=true',
`-Djava.library.path=${nativePath}`, `-Djava.library.path=${nativePath}`,
`-Xmx${this.options.memory.max}M`, `-Xmx${this.options.memory.max}M`,
`-Xms${this.options.memory.min}M` `-Xms${this.options.memory.min}M`
] ]
if (this.handler.getOS() === 'osx') { if (this.handler.getOS() === 'osx') {
if (parseInt(versionFile.id.split('.')[1]) > 12) jvm.push(await this.handler.getJVM()) if (parseInt(versionFile.id.split('.')[1]) > 12) jvm.push(await this.handler.getJVM())

View file

@ -1,6 +1,6 @@
{ {
"name": "minecraft-launcher-core", "name": "minecraft-launcher-core",
"version": "3.14.1", "version": "3.14.2",
"description": "Lightweight module that downloads and runs Minecraft using javascript / NodeJS", "description": "Lightweight module that downloads and runs Minecraft using javascript / NodeJS",
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {