From aff0c29f1760171b6c9cbe211907310b832a833b Mon Sep 17 00:00:00 2001 From: Pierce Date: Sun, 23 Aug 2020 23:57:28 -0400 Subject: [PATCH] Merge #51 with a few changes --- components/handler.js | 19 +++++++++++++++++++ components/launcher.js | 4 ++-- package.json | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/components/handler.js b/components/handler.js index 458191c..0d630ed 100644 --- a/components/handler.js +++ b/components/handler.js @@ -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) { if (options.clientPackage.startsWith('http')) { await this.downloadAsync(options.clientPackage, options.root, 'clientPackage.zip', true, 'client-package') diff --git a/components/launcher.js b/components/launcher.js index 6050b72..2617241 100644 --- a/components/launcher.js +++ b/components/launcher.js @@ -99,8 +99,8 @@ class MCLCore extends EventEmitter { '-Dfml.ignorePatchDiscrepancies=true', '-Dfml.ignoreInvalidMinecraftCertificates=true', `-Djava.library.path=${nativePath}`, - `-Xmx${this.options.memory.max}`, - `-Xms${this.options.memory.min}` + `-Xmx${this.handler.getMemory()[0]}`, + `-Xms${this.handler.getMemory()[1]}` ] if (this.handler.getOS() === 'osx') { if (parseInt(versionFile.id.split('.')[1]) > 12) jvm.push(await this.handler.getJVM()) diff --git a/package.json b/package.json index 3f8f635..633d877 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minecraft-launcher-core", - "version": "3.14.6", + "version": "3.15.0", "description": "Lightweight module that downloads and runs Minecraft using javascript / NodeJS", "main": "index.js", "dependencies": {