mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-12-23 10:23:47 +03:00
Small changes, non breaking this time
Removed getPid in favor of returning the child process instead. Added OS detection as well!
This commit is contained in:
parent
62d02dccba
commit
e5e1d68883
4 changed files with 24 additions and 22 deletions
|
@ -45,8 +45,7 @@ launcher.on('error', (e) => console.log(e));
|
|||
|
||||
| Function | Type | Description |
|
||||
|----------|---------|-----------------------------------------------------------------------------------------|
|
||||
| `launch` | Promise | Launches the client with the specified `options` as a parameter |
|
||||
| `getPid` | Integer | Returns the Minecraft client's PID |
|
||||
| `launch` | Promise | Launches the client with the specified `options` as a parameter. Returns child the process |
|
||||
|
||||
##### launch
|
||||
|
||||
|
@ -54,7 +53,7 @@ launcher.on('error', (e) => console.log(e));
|
|||
|--------------------------|----------|-------------------------------------------------------------------------------------------|----------|
|
||||
| `options.clientPackage` | String | Path to the client package zip file. | 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, | True |
|
||||
| `options.os` | String | windows, osx or linux. MCLC with auto determine the OS if this field isn't provided. | 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 |
|
||||
| `options.memory.max` | String | Max amount of memory being used by Minectaft. | True |
|
||||
|
|
|
@ -171,7 +171,7 @@ class Handler {
|
|||
|
||||
await Promise.all(this.version.libraries.map(async (lib) => {
|
||||
if (!lib.downloads.classifiers) return;
|
||||
const type = `natives-${this.options.os}`;
|
||||
const type = `natives-${this.getOS()}`;
|
||||
const native = lib.downloads.classifiers[type];
|
||||
|
||||
if (native) {
|
||||
|
@ -354,15 +354,24 @@ class Handler {
|
|||
}
|
||||
|
||||
async getJVM() {
|
||||
switch(this.options.os) {
|
||||
case "windows": {
|
||||
return "-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump"
|
||||
}
|
||||
case "osx": {
|
||||
return "-XstartOnFirstThread"
|
||||
}
|
||||
case "linux": {
|
||||
return "-Xss1M"
|
||||
const opts = {
|
||||
"windows": "-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump",
|
||||
"osx": "-XstartOnFirstThread",
|
||||
"linux": "-Xss1M"
|
||||
};
|
||||
return opts[this.getOS()]
|
||||
}
|
||||
|
||||
getOS() {
|
||||
if(this.options.os) {
|
||||
return this.options.os;
|
||||
} else {
|
||||
switch(process.platform) {
|
||||
case "win32": return "windows";
|
||||
case "darwin": return "osx";
|
||||
case "freebsd": return "linux";
|
||||
case "sunos": return "linux";
|
||||
default: throw Error("[MCLC Error] Couldn't set OS specific JVM argument!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ const EventEmitter = require('events').EventEmitter;
|
|||
class MCLCore extends EventEmitter {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.pid = null;
|
||||
}
|
||||
|
||||
async launch(options) {
|
||||
|
@ -69,7 +67,7 @@ class MCLCore extends EventEmitter {
|
|||
|
||||
const classes = await this.handler.getClasses();
|
||||
let classPaths = ['-cp'];
|
||||
const separator = this.options.os === "windows" ? ";" : ":";
|
||||
const separator = this.handler.getOS() === "windows" ? ";" : ":";
|
||||
this.emit('debug', `[MCLC]: Using ${separator} to separate class paths`);
|
||||
if(forge) {
|
||||
this.emit('debug', '[MCLC]: Setting Forge class paths');
|
||||
|
@ -99,11 +97,7 @@ class MCLCore extends EventEmitter {
|
|||
minecraft.stderr.on('data', (data) => this.emit('error', data));
|
||||
minecraft.on('close', (code) => this.emit('close', code));
|
||||
|
||||
this.pid = minecraft.pid;
|
||||
}
|
||||
|
||||
getPid() {
|
||||
return this.pid;
|
||||
return minecraft;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "minecraft-launcher-core",
|
||||
"version": "3.4.0",
|
||||
"version": "3.5.0",
|
||||
"description": "Lightweight module that downloads and runs Minecraft using javascript / NodeJS",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
|
|
Loading…
Add table
Reference in a new issue