mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-11-05 21:23:59 +03:00
v3.11
Better handling of Forge when it doesnt have a version.json. remove package.js and moved it to main handler file. display whether or not java is 64 or 32 bit.
This commit is contained in:
parent
8291f9a15d
commit
3fbea961c8
5 changed files with 32 additions and 33 deletions
|
@ -60,9 +60,10 @@ launcher.on('data', (e) => console.log(e));
|
|||
| Parameter | Type | Description | Required |
|
||||
|--------------------------|----------|-------------------------------------------------------------------------------------------|----------|
|
||||
| `options.clientPackage` | String | Path or URL to the client package zip file. | False |
|
||||
| `options.removePackage` | Boolean | Option to remove the client package zip file after its finished extracting. | False |
|
||||
| `options.installer` | String | Path to installer being executed. | False |
|
||||
| `options.root` | String | Path where you want the launcher to work in. like `C:/Users/user/AppData/Roaming/.mc`, | True |
|
||||
| `options.os` | String | windows, osx or linux. MCLC with auto determine the OS if this field isn't provided. | False |
|
||||
| `options.os` | String | windows, osx or linux. MCLC will auto determine the OS if this field isn't provided. | False |
|
||||
| `options.customArgs` | Array | Array of custom java arguments you want to add. | False |
|
||||
| `options.version.number` | String | Minecraft version that is going to be launched. | True |
|
||||
| `options.version.type` | String | Any string. The actual Minecraft launcher uses `release` and `snapshot`. | True |
|
||||
|
|
|
@ -20,22 +20,18 @@ class Handler {
|
|||
|
||||
checkJava(java) {
|
||||
return new Promise(resolve => {
|
||||
let spawned = false;
|
||||
const javaVer = child.spawn(java, ["-version"]);
|
||||
javaVer.stderr.on('data', (data) => {
|
||||
if (spawned) return;
|
||||
spawned = true;
|
||||
this.client.emit('debug', `[MCLC]: Using Java version ${data.toString().match(/"(.*?)"/).pop()}`);
|
||||
child.exec(`${java} -version`, (error, stdout, stderr) => {
|
||||
if(error) {
|
||||
resolve({
|
||||
run: false,
|
||||
message: e
|
||||
})
|
||||
}
|
||||
this.client.emit('debug', `[MCLC]: Using Java version ${stderr.match(/"(.*?)"/).pop()} ${stderr.includes('64-Bit') ? '64-bit': '32-Bit'}`);
|
||||
resolve({
|
||||
run: true
|
||||
});
|
||||
});
|
||||
javaVer.on('error', (e) => {
|
||||
resolve({
|
||||
run: false,
|
||||
message: e
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -297,7 +293,13 @@ class Handler {
|
|||
if(!fs.existsSync(path.join(this.options.root, 'forge'))) {
|
||||
shelljs.mkdir('-p', path.join(this.options.root, 'forge'));
|
||||
}
|
||||
await new zip(this.options.forge).extractEntryTo('version.json', path.join(this.options.root, 'forge', `${this.version.id}`), false, true);
|
||||
|
||||
try {
|
||||
await new zip(this.options.forge).extractEntryTo('version.json', path.join(this.options.root, 'forge', `${this.version.id}`), false, true);
|
||||
} catch(e) {
|
||||
this.client.emit('debug', `[MCLC]: Unable to extract version.json from the forge jar due to ${e}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
const forge = require(path.join(this.options.root, 'forge', `${this.version.id}`, 'version.json'));
|
||||
const paths = [];
|
||||
|
@ -528,6 +530,19 @@ class Handler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
extractPackage(options = this.options) {
|
||||
return new Promise(async resolve => {
|
||||
if(options.clientPackage.startsWith('http')) {
|
||||
await this.downloadAsync(options.clientPackage, options.root, "clientPackage.zip", true, 'client-package');
|
||||
options.clientPackage = path.join(options.root, "clientPackage.zip")
|
||||
}
|
||||
new zip(options.clientPackage).extractAllTo(options.root, true);
|
||||
this.client.emit('package-extract', true);
|
||||
if(options.removePackage) shelljs.rm(options.clientPackage);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Handler;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const child = require('child_process');
|
||||
const path = require('path');
|
||||
const handler = require('./handler');
|
||||
const packager = require('./package');
|
||||
const fs = require('fs');
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
|
||||
|
@ -42,7 +41,7 @@ class MCLCore extends EventEmitter {
|
|||
|
||||
if(this.options.clientPackage) {
|
||||
this.emit('debug', `[MCLC]: Extracting client package to ${this.options.root}`);
|
||||
await packager.extractPackage(this);
|
||||
await this.handler.extractPackage();
|
||||
}
|
||||
|
||||
if(this.options.installer) {
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
const path = require('path');
|
||||
const zip = require('adm-zip');
|
||||
const shelljs = require('shelljs');
|
||||
|
||||
module.exports.extractPackage = function(e) {
|
||||
return new Promise(async resolve => {
|
||||
if(e.options.clientPackage.startsWith('http')) {
|
||||
await e.handler.downloadAsync(e.options.clientPackage, e.options.root, "clientPackage.zip", true, 'client-package');
|
||||
e.options.clientPackage = path.join(e.options.root, "clientPackage.zip")
|
||||
}
|
||||
new zip(e.options.clientPackage).extractAllTo(e.options.root, true);
|
||||
e.emit('package-extract', true);
|
||||
shelljs.rm(e.options.clientPackage);
|
||||
resolve();
|
||||
});
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "minecraft-launcher-core",
|
||||
"version": "3.10.4",
|
||||
"version": "3.11.0",
|
||||
"description": "Lightweight module that downloads and runs Minecraft using javascript / NodeJS",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
|
|
Loading…
Reference in a new issue