Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanro50 committed Mar 11, 2023
1 parent 0e3970b commit 8863f28
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 40 deletions.
96 changes: 57 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,55 @@ At the moment you can get support via Discord (link above).
# Examples
## A basic ES6 example with [MCLC](https://github.com/Pierce01/MinecraftLauncher-core)
```js
import msmc, { wrapError } from "msmc";
import { Client, Authenticator } from "minecraft-launcher-core";
const launcher = new Client();//We're simple setting up mclc here...
const auth = new msmc.auth(); //Spawn a new auth object using mojang's token


auth.on('load', console.log) //read load events into the console
try{
const xbx = await auth.launch('raw')//In the example we use raw, but you can replace the word raw with electron or nwjs if you're using either of the two
const mc = await xbx.getMinecraft()//Lets get the information we need to launch minecraft
import { Client } from "minecraft-launcher-core";
const launcher = new Client();
//Import the auth class
import { auth } from "msmc";
//Create a new auth manager
const authManager = new auth("select_account");
//Launch using the 'raw' gui framework (can be 'electron' or 'nwjs')
const xboxManager = await authManager.launch("raw")
//Generate the minecraft login token
const token = await xboxManager.getMinecraft();
// Pulled from the Minecraft Launcher core docs.
let opts = {
clientPackage: null,
// Simply call this function to convert the msmc minecraft object into a mclc authorization object
authorization: token.mclc(),
root: "./.minecraft",
version: {
number: "1.18.2",
type: "release"
},
memory: {
max: "6G",
min: "4G"
}
};
console.log("Starting!");
launcher.launch(opts);

launcher.on('debug', (e) => console.log(e));
launcher.on('data', (e) => console.log(e));
```
## A basic commonJS example with [MCLC](https://github.com/Pierce01/MinecraftLauncher-core)
```js
const { Client } = require("minecraft-launcher-core");
const launcher = new Client();
//Import the auth class
const { auth } = require("msmc");
//Create a new auth manager
const authManager = new auth("select_account");
//Launch using the 'raw' gui framework (can be 'electron' or 'nwjs')
authManager.launch("raw").then(async xboxManager => {
//Generate the minecraft login token
const token = await xboxManager.getMinecraft();
// Pulled from the Minecraft Launcher core docs.
let opts = {
clientPackage: null,
// Simply call this function to convert the msmc minecraft object into a mclc authorization object
authorization: mc.mclc(),
root: "./minecraft",
authorization: token.mclc(),
root: "./.minecraft",
version: {
number: "1.18.2",
type: "release"
Expand All @@ -41,16 +73,13 @@ try{
max: "6G",
min: "4G"
}
}
console.log("Starting!")
};
console.log("Starting!");
launcher.launch(opts);

launcher.on('debug', (e) => console.log(e));
launcher.on('data', (e) => console.log(e));
}catch(e){
console.log(wrapError(e)) // The wrap error function is here to convert an msmc error into something we can decode.
}

});
```
## A basic commonJS example with [GMLL](https://github.com/Hanro50/GMLL)
```js
Expand All @@ -60,22 +89,16 @@ const gmll = require("gmll");
const { auth } = require("msmc");

gmll.init().then(async () => {
//Create a new auth manager
const authManager = new auth("select_account");
//Launch using the 'raw' gui framework (can be 'electron' or 'nwjs')
const xboxManager = await authManager.launch("raw")
//Generate the minecraft login token
const token = await xboxManager.getMinecraft()

var int = new gmll.instance()
//Launch with the gmll token
int.launch(token.gmll());

try {
} catch (e) {
console.trace(e)
}

//Create a new auth manager
const authManager = new auth("select_account");
//Launch using the 'raw' gui framework (can be 'electron' or 'nwjs')
const xboxManager = await authManager.launch("raw")
//Generate the minecraft login token
const token = await xboxManager.getMinecraft()

var int = new gmll.instance()
//Launch with the gmll token
int.launch(token.gmll());
})
```
## A basic ES6 example with [GMLL](https://github.com/Hanro50/GMLL)
Expand All @@ -96,11 +119,6 @@ var int = new instance()
//Launch with the gmll token
int.launch(token.gmll());

try {
} catch (e) {
console.trace(e)
}

```
# Modules
## auth
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "msmc",
"version": "4.0.2",
"version": "4.0.3",
"description": "A bare bones login library for Minecraft based projects to authenticate individuals with a Microsoft account.",
"license": "MIT",
"exports": {
Expand Down
1 change: 1 addition & 0 deletions tests/raw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"dependencies": {
"@types/node": "^17.0.35",
"minecraft-launcher-core": "^3.16.18",
"msmc": "file:../../"
},
"scripts": {
Expand Down
30 changes: 30 additions & 0 deletions tests/raw/test2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Client } from "minecraft-launcher-core";
const launcher = new Client();
//Import the auth class
import { auth } from "msmc";
//Create a new auth manager
const authManager = new auth("select_account");
//Launch using the 'raw' gui framework (can be 'electron' or 'nwjs')
const xboxManager = await authManager.launch("raw")
//Generate the minecraft login token
const token = await xboxManager.getMinecraft();
// Pulled from the Minecraft Launcher core docs.
let opts = {
clientPackage: null,
// Simply call this function to convert the msmc minecraft object into a mclc authorization object
authorization: token.mclc(),
root: "./.minecraft",
version: {
number: "1.18.2",
type: "release"
},
memory: {
max: "6G",
min: "4G"
}
};
console.log("Starting!");
launcher.launch(opts);

launcher.on('debug', (e) => console.log(e));
launcher.on('data', (e) => console.log(e));

0 comments on commit 8863f28

Please sign in to comment.