mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-11-22 12:16:21 +03:00
Better documentation
This commit is contained in:
parent
27ccc91b0d
commit
5a813d99cc
1 changed files with 74 additions and 38 deletions
112
README.md
112
README.md
|
@ -3,27 +3,75 @@
|
||||||
|
|
||||||
A script that launches Minecraft using NodeJS.
|
A script that launches Minecraft using NodeJS.
|
||||||
|
|
||||||
#### Installing
|
### Installing
|
||||||
|
|
||||||
`npm i minecraft-launcher-core`
|
`npm i minecraft-launcher-core`
|
||||||
|
|
||||||
#### Usage
|
### Usage
|
||||||
|
|
||||||
##### Basic Login
|
|
||||||
|
##### launcher.core Options
|
||||||
|
|
||||||
|
| Parameter | Type | Description | Required |
|
||||||
|
|------------------|----------|-------------------------------------------------------------------------------------------|----------|
|
||||||
|
| `authorization` | Object | The result from `getAuth` function, allows the client to login in online or offline mode. | True |
|
||||||
|
| `clientPackage` | String | Path to the client package zip file. | False |
|
||||||
|
| `root` | String | Path where you want the launcher to work in. like `C:/Users/user/AppData/Roaming/.mc` | True |
|
||||||
|
| `os` | String | windows, osx or linux | True |
|
||||||
|
| `version.number` | String | Minecraft version that is going to be launched. | True |
|
||||||
|
| `version.type` | String | Any string. The actual Minecraft launcher uses `release` and `snapshot`. | True |
|
||||||
|
| `memory.max` | String | Max amount of memory being used by Minectaft | True |
|
||||||
|
|
||||||
|
#### launcher.authenticator Functions
|
||||||
|
|
||||||
|
##### getAuth
|
||||||
|
|
||||||
|
| Parameter | Type | Description | Required |
|
||||||
|
|-----------|--------|--------------------------------------------------------------|----------|
|
||||||
|
| `email` | String | Email or username | True |
|
||||||
|
| `password` | String | Password for the Mojang account being used if online mode. | False |
|
||||||
|
|
||||||
|
##### validate
|
||||||
|
|
||||||
|
| Parameter | Type | Description | Required |
|
||||||
|
|--------------|--------|-------------------------------------------------------------------|----------|
|
||||||
|
| `access_token` | String | Token being checked if it can be used to login with (online mode). | True |
|
||||||
|
|
||||||
|
##### refreshAuth
|
||||||
|
|
||||||
|
| Parameter | Type | Description | Required |
|
||||||
|
|--------------------|--------|-------------------------------------------------------------------------------------|----------|
|
||||||
|
| `access_token` | String | Token being checked if it can be used to login with (online mode). | True |
|
||||||
|
| `client_token` | String | Token being checked if it's the same client that the access_token was created from. | True |
|
||||||
|
| `selected_profile` | Object | Json Object that was returned from Mojangs auth api. | True |
|
||||||
|
|
||||||
|
#### Client Package Function
|
||||||
|
|
||||||
|
Client Packages allow the client to run offline on setup. This function should be used outside the actual launcher.
|
||||||
|
this function is in the `handler` component.
|
||||||
|
|
||||||
|
##### makePackage
|
||||||
|
|
||||||
|
| Parameter | Type | Description | Required |
|
||||||
|
|------------|--------|-----------------------------------------------------------------------|----------|
|
||||||
|
| `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 |
|
||||||
|
|
||||||
|
|
||||||
|
### Examples
|
||||||
```javascript
|
```javascript
|
||||||
const launcher = require('./pathtomodule');
|
const launcher = require('minecraft-launcher-core');
|
||||||
|
|
||||||
launcher.authenticator.getAuth("email", "password").then(auth => {
|
launcher.authenticator.getAuth("email", "password").then(auth => {
|
||||||
// Save the auth to a file so it can be used later on!
|
// Save the auth to a file so it can be used later on!
|
||||||
launcher.core({
|
launcher.core({
|
||||||
authorization: auth,
|
authorization: auth,
|
||||||
clientPackage: null,
|
clientPackage: null,
|
||||||
// All of the following is required
|
root: "C:/Users/user/AppData/Roaming/.mc",
|
||||||
root: "directory", // C:/Users/user/AppData/Roaming/.mc
|
os: "windows",
|
||||||
os: "windows", // windows, osx, linux
|
|
||||||
version: {
|
version: {
|
||||||
number: "1.13.2", // Minecraft version you want to launch
|
number: "1.13.2",
|
||||||
type: "MCC-Launcher" // Type. Can be anything
|
type: "MCC-Launcher"
|
||||||
},
|
},
|
||||||
memory: {
|
memory: {
|
||||||
max: "500"
|
max: "500"
|
||||||
|
@ -35,38 +83,26 @@ launcher.authenticator.getAuth("email", "password").then(auth => {
|
||||||
##### Using Validate and Refresh
|
##### Using Validate and Refresh
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
let auth = require("pathToUserAuthJson.json");
|
let auth = require("pathToUserAuthJson.json");
|
||||||
|
|
||||||
const validateCheck = await launcher.authenticator.validate(auth.access_token); // required arguments.
|
const validateCheck = await launcher.authenticator.validate(auth.access_token);
|
||||||
if(!validateCheck) {
|
if(!validateCheck) {
|
||||||
auth = await launcher.authenticator.refreshAuth(auth.access_token, auth.client_token, auth.selected_profile); // required arguments.
|
auth = await launcher.authenticator.refreshAuth(auth.access_token, auth.client_token, auth.selected_profile);
|
||||||
|
}
|
||||||
|
launcher.core({
|
||||||
|
authorization: auth,
|
||||||
|
clientPackage: null,
|
||||||
|
root: "directory",
|
||||||
|
os: "windows",
|
||||||
|
version: {
|
||||||
|
number: "1.13.2",
|
||||||
|
type: "MCC-Launcher"
|
||||||
|
},
|
||||||
|
memory: {
|
||||||
|
max: "500"
|
||||||
}
|
}
|
||||||
launcher.core({
|
|
||||||
authorization: auth,
|
|
||||||
clientPackage: null,
|
|
||||||
// All of the following is required
|
|
||||||
root: "directory", // C:/Users/user/AppData/Roaming/.mc
|
|
||||||
os: "windows", // windows, osx, linux
|
|
||||||
version: {
|
|
||||||
number: "1.13.2", // Minecraft version you want to launch
|
|
||||||
type: "MCC-Launcher" // Type. Can be anything
|
|
||||||
},
|
|
||||||
memory: {
|
|
||||||
max: "500"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
```
|
``
|
||||||
|
|
||||||
#### Client Packages
|
|
||||||
|
|
||||||
Client Packages allow the client to run offline on setup.
|
|
||||||
|
|
||||||
* makePackage - `launcher.handler.makePackage(["arrayOfVersions"], "os");`
|
|
||||||
* extractPackage - `launcher.handler.extractPackage("directory", "packageDirectory")`
|
|
||||||
|
|
||||||
If you're using a clientPackage, change `null` for `clientPackage` to the zip directory in the example.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### What should it look like running from console?
|
#### What should it look like running from console?
|
||||||
|
|
Loading…
Add table
Reference in a new issue