mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-11-06 05:33:58 +03:00
Added Proxy and Server launch options. Reformted stuff
This commit is contained in:
parent
2652654c18
commit
a2e166dfe1
5 changed files with 84 additions and 38 deletions
88
README.md
88
README.md
|
@ -8,6 +8,39 @@ Basically a core for your Electron or script based launchers.
|
||||||
|
|
||||||
`npm i minecraft-launcher-core`
|
`npm i minecraft-launcher-core`
|
||||||
|
|
||||||
|
### Standard Example
|
||||||
|
```javascript
|
||||||
|
const launcher = require('minecraft-launcher-core');
|
||||||
|
|
||||||
|
launcher.authenticator.getAuth("email", "password").then(auth => {
|
||||||
|
// Save the auth to a file so it can be used later on!
|
||||||
|
launcher.core({
|
||||||
|
authorization: auth,
|
||||||
|
clientPackage: null,
|
||||||
|
forge: null,
|
||||||
|
root: "C:/Users/user/AppData/Roaming/.mc",
|
||||||
|
os: "windows",
|
||||||
|
version: {
|
||||||
|
number: "1.13.2",
|
||||||
|
type: "release"
|
||||||
|
},
|
||||||
|
memory: {
|
||||||
|
max: "3000",
|
||||||
|
min: "1000"
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
host: "server.url",
|
||||||
|
port: "25565"
|
||||||
|
},
|
||||||
|
proxy: {
|
||||||
|
host: "proxy.url",
|
||||||
|
port: "8080",
|
||||||
|
username: "username",
|
||||||
|
password: "password"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
##### launcher.core Options
|
##### launcher.core Options
|
||||||
|
@ -22,6 +55,12 @@ Basically a core for your Electron or script based launchers.
|
||||||
| `options.version.type` | String | Any string. The actual Minecraft launcher uses `release` and `snapshot`. | 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 |
|
| `options.memory.max` | String | Max amount of memory being used by Minectaft | True |
|
||||||
| `options.forge.path` | String | Path to Universal Forge Jar | False |
|
| `options.forge.path` | String | Path to Universal Forge Jar | False |
|
||||||
|
| `options.server.host` | String | Host url to the server, don't include the port | False |
|
||||||
|
| `options.server.port` | String | Port of the host url, will default to `25565` if not entered. | False |
|
||||||
|
| `options.proxy.host` | String | Host url to the proxy, don't include the port | False |
|
||||||
|
| `options.proxy.port` | String | Port of the host proxy, will default to `8080` if not entered. | False |
|
||||||
|
| `options.proxy.username` | String | Username for the proxy. | False |
|
||||||
|
| `options.proxy.password` | String | Password for the proxy. | False |
|
||||||
|
|
||||||
#### launcher.authenticator Functions
|
#### launcher.authenticator Functions
|
||||||
|
|
||||||
|
@ -69,28 +108,7 @@ this function is in the `handler` component.
|
||||||
| `versions` | Array | Array of the versions being downloaded and being made into a package. | True |
|
| `versions` | Array | Array of the versions being downloaded and being made into a package. | True |
|
||||||
| `os` | String | OS that the package will be loaded on. OS specific natives need this. | True |
|
| `os` | String | OS that the package will be loaded on. OS specific natives need this. | True |
|
||||||
|
|
||||||
### Examples
|
### Other Examples
|
||||||
```javascript
|
|
||||||
const launcher = require('minecraft-launcher-core');
|
|
||||||
|
|
||||||
launcher.authenticator.getAuth("email", "password").then(auth => {
|
|
||||||
// Save the auth to a file so it can be used later on!
|
|
||||||
launcher.core({
|
|
||||||
authorization: auth,
|
|
||||||
clientPackage: null,
|
|
||||||
forge: null,
|
|
||||||
root: "C:/Users/user/AppData/Roaming/.mc",
|
|
||||||
os: "windows",
|
|
||||||
version: {
|
|
||||||
number: "1.13.2",
|
|
||||||
type: "MCC-Launcher"
|
|
||||||
},
|
|
||||||
memory: {
|
|
||||||
max: "500"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Using Validate and Refresh
|
##### Using Validate and Refresh
|
||||||
|
|
||||||
|
@ -111,7 +129,18 @@ launcher.core({
|
||||||
type: "MCC-Launcher"
|
type: "MCC-Launcher"
|
||||||
},
|
},
|
||||||
memory: {
|
memory: {
|
||||||
max: "500"
|
max: "500",
|
||||||
|
min: "100"
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
host: "server.url",
|
||||||
|
port: "25565"
|
||||||
|
},
|
||||||
|
proxy: {
|
||||||
|
host: "proxy.url",
|
||||||
|
port: "8080",
|
||||||
|
username: "username",
|
||||||
|
password: "password"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
@ -133,7 +162,18 @@ launcher.authenticator.getAuth("email", "password").then(auth => {
|
||||||
type: "MCC-Launcher"
|
type: "MCC-Launcher"
|
||||||
},
|
},
|
||||||
memory: {
|
memory: {
|
||||||
max: "500"
|
max: "500",
|
||||||
|
min: "100"
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
host: "server.url",
|
||||||
|
port: "25565"
|
||||||
|
},
|
||||||
|
proxy: {
|
||||||
|
host: "proxy.url",
|
||||||
|
port: "8080",
|
||||||
|
username: "username",
|
||||||
|
password: "password"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,7 +43,7 @@ function getAuth(username, password) {
|
||||||
uuid: body.selectedProfile.id,
|
uuid: body.selectedProfile.id,
|
||||||
name: body.selectedProfile.name,
|
name: body.selectedProfile.name,
|
||||||
selected_profile: body.selectedProfile,
|
selected_profile: body.selectedProfile,
|
||||||
user_properties: JSON.stringify((body.user || {}).properties || {})
|
user_properties: JSON.stringify(body.user.properties || {})
|
||||||
};
|
};
|
||||||
|
|
||||||
resolve(userProfile);
|
resolve(userProfile);
|
||||||
|
|
|
@ -217,12 +217,9 @@ module.exports.getClasses = function (root, version) {
|
||||||
|
|
||||||
module.exports.getLaunchOptions = function (version, forge, options) {
|
module.exports.getLaunchOptions = function (version, forge, options) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
let arguments;
|
let type = forge || version;
|
||||||
if(forge) {
|
let arguments = type.minecraftArguments ? type.minecraftArguments.split(' ') : type.arguments.game;
|
||||||
arguments = forge.minecraftArguments ? forge.minecraftArguments.split(' ') : forge.arguments.game;
|
|
||||||
} else {
|
|
||||||
arguments = version.minecraftArguments ? version.minecraftArguments.split(' ') : version.arguments.game;
|
|
||||||
}
|
|
||||||
const fields = {
|
const fields = {
|
||||||
'${auth_access_token}': options.authorization.access_token,
|
'${auth_access_token}': options.authorization.access_token,
|
||||||
'${auth_session}': options.authorization.access_token,
|
'${auth_session}': options.authorization.access_token,
|
||||||
|
@ -243,6 +240,18 @@ module.exports.getLaunchOptions = function (version, forge, options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(options.server) arguments.push('--server', options.server.host, '--port', options.server.port || "25565");
|
||||||
|
if(options.proxy) arguments.push(
|
||||||
|
'--proxyHost',
|
||||||
|
options.proxy.host,
|
||||||
|
'--proxyPort',
|
||||||
|
options.proxy.port || "8080",
|
||||||
|
'--proxyUser',
|
||||||
|
options.proxy.username,
|
||||||
|
'--proxyPass',
|
||||||
|
options.proxy.password
|
||||||
|
);
|
||||||
|
|
||||||
resolve(arguments);
|
resolve(arguments);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,6 +37,7 @@ module.exports = async function (options) {
|
||||||
'-Dfml.ignoreInvalidMinecraftCertificates=true',
|
'-Dfml.ignoreInvalidMinecraftCertificates=true',
|
||||||
`-Djava.library.path=${nativePath}`,
|
`-Djava.library.path=${nativePath}`,
|
||||||
`-Xmx${options.memory.max}M`,
|
`-Xmx${options.memory.max}M`,
|
||||||
|
`-Xms${options.memory.min}M`,
|
||||||
'-Xincgc'
|
'-Xincgc'
|
||||||
];
|
];
|
||||||
jvm.push(await handler.getJVM(versionFile, options));
|
jvm.push(await handler.getJVM(versionFile, options));
|
||||||
|
@ -55,13 +56,9 @@ module.exports = async function (options) {
|
||||||
// Download version's assets
|
// Download version's assets
|
||||||
await handler.getAssets(options.root, versionFile);
|
await handler.getAssets(options.root, versionFile);
|
||||||
|
|
||||||
// Launch options
|
// Launch options. Thank you Lyrus for the reformat <3
|
||||||
let launchOptions;
|
let launchOptions;
|
||||||
if(forge) {
|
launchOptions = await handler.getLaunchOptions(versionFile, forge ? forge.forge : null, options);
|
||||||
launchOptions = await handler.getLaunchOptions(versionFile, forge.forge, options);
|
|
||||||
} else {
|
|
||||||
launchOptions = await handler.getLaunchOptions(versionFile, null, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
const launchArguments = args.concat(jvm, classPaths, launchOptions);
|
const launchArguments = args.concat(jvm, classPaths, launchOptions);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "minecraft-launcher-core",
|
"name": "minecraft-launcher-core",
|
||||||
"version": "2.2.0",
|
"version": "2.3.0",
|
||||||
"description": "Module that downloads Minecraft assets and runs Minecraft. Also Supports Forge",
|
"description": "Module that downloads Minecraft assets and runs Minecraft. Also Supports Forge",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
Loading…
Reference in a new issue