Merge #51 with a few changes

This commit is contained in:
Pierce 2020-08-23 23:57:28 -04:00
parent 1f50ad1ff8
commit aff0c29f17
3 changed files with 22 additions and 3 deletions

View file

@ -557,6 +557,25 @@ class Handler {
} }
} }
// To prevent launchers from breaking when they update. Will be reworked with rewrite.
getMemory () {
if (!this.options.memory) {
this.client.emit('debug', '[MCLC]: Memory not set! Setting 1GB as MAX!')
this.options.memory = {
min: 512,
max: 1023
}
}
if (!isNaN(this.options.memory.max) && !isNaN(this.options.memory.min)) {
if (this.options.memory.max < this.options.memory.min) {
this.client.emit('debug', '[MCLC]: MIN memory is higher then MAX! Resetting!')
this.options.memory.max = 1023
this.options.memory.min = 512
}
return [`${this.options.memory.max}M`, `${this.options.memory.min}M`]
} else { return [`${this.options.memory.max}`, `${this.options.memory.min}`] }
}
async extractPackage (options = this.options) { async extractPackage (options = this.options) {
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')

View file

@ -99,8 +99,8 @@ class MCLCore extends EventEmitter {
'-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}`, `-Xmx${this.handler.getMemory()[0]}`,
`-Xms${this.options.memory.min}` `-Xms${this.handler.getMemory()[1]}`
] ]
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.6", "version": "3.15.0",
"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": {