mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-12-23 02:13:46 +03:00
Merged #52 & removed shelljs
The `gameDirectory` option was moved to `overrides` to keep consistancy as it's for devs that go above and beyond with their launchers.
This commit is contained in:
parent
5b21305f99
commit
6eb2a7eb78
5 changed files with 39 additions and 57 deletions
|
@ -64,7 +64,6 @@ launcher.on('data', (e) => console.log(e));
|
|||
| `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.gameDirectofy` | String | Path where you want the game to work in. If you don't specify it, it will be in the same place as root.| False |
|
||||
| `options.os` | String | windows, osx or linux. MCLC will auto determine the OS if this field isn't provided. | False |
|
||||
| `options.customLaunchArgs`| Array | Array of custom Minecraft arguments you want to add. | False |
|
||||
| `options.customArgs` | Array | Array of custom Java arguments you want to add. | False |
|
||||
|
@ -86,12 +85,12 @@ launcher.on('data', (e) => console.log(e));
|
|||
| `options.window.height` | String | Height of the Minecraft Client. | False |
|
||||
| `options.window.fullscreen` | Boolean| Fullscreen the Minecraft Client. | False |
|
||||
| `options.overrides` | Object | Json object redefining paths for better customization. Example below. | False |
|
||||
| `options.overrides.minArgs`| Integer| The amount of launch arguments specified in the version file before it adds the default again| False |
|
||||
#### IF YOU'RE NEW TO MCLC, LET IT HANDLE EVERYTHING! DO NOT USE OVERRIDES!
|
||||
```js
|
||||
let opts = {
|
||||
otherOps...,
|
||||
overrides: {
|
||||
gameDirectory: "", // where the game process generates folders like saves and resource packs.
|
||||
minecraftJar: "",
|
||||
versionJson: "",
|
||||
directory: "", // where the Minecraft jar and version json are located.
|
||||
|
@ -101,7 +100,7 @@ let opts = {
|
|||
cwd: "", // working directory of the java process.
|
||||
detached: true, // whether or not the client is detached from the parent / launcher.
|
||||
classes: [], // all class paths are required if you use this.
|
||||
minArgs: 11,
|
||||
minArgs: 11, // The amount of launch arguments specified in the version file before it adds the default again
|
||||
maxSockets: 2, // max sockets for downloadAsync.
|
||||
// The following is for launcher developers located in countries that have the Minecraft and Forge resource servers
|
||||
// blocked for what ever reason. They obviously need to mirror the formatting of the original JSONs / file structures.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const fs = require('fs')
|
||||
const shelljs = require('shelljs')
|
||||
const path = require('path')
|
||||
const request = require('request')
|
||||
const checksum = require('checksum')
|
||||
|
@ -37,7 +36,7 @@ class Handler {
|
|||
|
||||
downloadAsync (url, directory, name, retry, type) {
|
||||
return new Promise(resolve => {
|
||||
shelljs.mkdir('-p', directory)
|
||||
fs.mkdirSync(directory, { recursive: true })
|
||||
|
||||
const _request = this.baseRequest(url)
|
||||
|
||||
|
@ -84,7 +83,7 @@ class Handler {
|
|||
file.on('error', async (e) => {
|
||||
this.client.emit('debug', `[MCLC]: Failed to download asset to ${path.join(directory, name)} due to\n${e}.` +
|
||||
` Retrying... ${retry}`)
|
||||
if (fs.existsSync(path.join(directory, name))) shelljs.rm(path.join(directory, name))
|
||||
if (fs.existsSync(path.join(directory, name))) fs.unlinkSync(path.join(directory, name))
|
||||
if (retry) await this.downloadAsync(url, directory, name, false, type)
|
||||
resolve()
|
||||
})
|
||||
|
@ -193,7 +192,7 @@ class Handler {
|
|||
legacyAsset.pop()
|
||||
|
||||
if (!fs.existsSync(path.join(assetDirectory, 'legacy', legacyAsset.join('/')))) {
|
||||
shelljs.mkdir('-p', path.join(assetDirectory, 'legacy', legacyAsset.join('/')))
|
||||
fs.mkdirSync(path.join(assetDirectory, 'legacy', legacyAsset.join('/')), { recursive: true })
|
||||
}
|
||||
|
||||
if (!fs.existsSync(path.join(assetDirectory, 'legacy', asset))) {
|
||||
|
@ -234,7 +233,7 @@ class Handler {
|
|||
const nativeDirectory = path.resolve(this.options.overrides.natives || path.join(this.options.root, 'natives', this.version.id))
|
||||
|
||||
if (!fs.existsSync(nativeDirectory) || !fs.readdirSync(nativeDirectory).length) {
|
||||
shelljs.mkdir('-p', nativeDirectory)
|
||||
fs.mkdirSync(nativeDirectory, { recursive: true })
|
||||
|
||||
const natives = async () => {
|
||||
const natives = []
|
||||
|
@ -273,7 +272,7 @@ class Handler {
|
|||
// All is well.
|
||||
console.warn(e)
|
||||
}
|
||||
shelljs.rm(path.join(nativeDirectory, name))
|
||||
fs.unlinkSync(path.join(nativeDirectory, name))
|
||||
counter++
|
||||
this.client.emit('progress', {
|
||||
type: 'natives',
|
||||
|
@ -293,7 +292,7 @@ class Handler {
|
|||
// Not bothering to rewrite this.
|
||||
async getForgeDependenciesLegacy () {
|
||||
if (!fs.existsSync(path.join(this.options.root, 'forge'))) {
|
||||
shelljs.mkdir('-p', path.join(this.options.root, 'forge'))
|
||||
fs.mkdirSync(path.join(this.options.root, 'forge'), { recursive: true })
|
||||
}
|
||||
|
||||
const zipFile = new Zip(this.options.forge)
|
||||
|
@ -346,7 +345,7 @@ class Handler {
|
|||
this.client.emit('progress', { type: 'forge', task: counter, total: forge.libraries.length })
|
||||
return
|
||||
}
|
||||
if (!fs.existsSync(jarPath)) shelljs.mkdir('-p', jarPath)
|
||||
if (!fs.existsSync(jarPath)) fs.mkdirSync(jarPath, { recursive: true })
|
||||
|
||||
const download = await this.downloadAsync(downloadLink, jarPath, name, true, 'forge')
|
||||
if (!download) await this.downloadAsync(`${this.options.overrides.url.fallbackMaven}${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}/${name}`, jarPath, name, true, 'forge')
|
||||
|
@ -497,7 +496,7 @@ class Handler {
|
|||
'${user_type}': 'mojang',
|
||||
'${version_name}': this.options.version.number,
|
||||
'${assets_index_name}': this.version.assetIndex.id,
|
||||
'${game_directory}': this.options.gameDirectory || this.options.root,
|
||||
'${game_directory}': this.options.overrides.gameDirectory || this.options.root,
|
||||
'${assets_root}': assetPath,
|
||||
'${game_assets}': assetPath,
|
||||
'${version_type}': this.options.version.type
|
||||
|
@ -564,7 +563,7 @@ class Handler {
|
|||
options.clientPackage = path.join(options.root, 'clientPackage.zip')
|
||||
}
|
||||
new Zip(options.clientPackage).extractAllTo(options.root, true)
|
||||
if (options.removePackage) shelljs.rm(options.clientPackage)
|
||||
if (options.removePackage) fs.unlinkSync(options.clientPackage)
|
||||
|
||||
return this.client.emit('package-extract', true)
|
||||
}
|
||||
|
|
|
@ -8,9 +8,6 @@ class MCLCore extends EventEmitter {
|
|||
async launch (options) {
|
||||
this.options = options
|
||||
this.options.root = path.resolve(this.options.root)
|
||||
if (this.options.gameDirectory) {
|
||||
this.options.gameDirectory = path.resolve(this.options.gameDirectory)
|
||||
}
|
||||
this.options.overrides = {
|
||||
detached: true,
|
||||
...this.options.overrides,
|
||||
|
@ -48,6 +45,13 @@ class MCLCore extends EventEmitter {
|
|||
fs.mkdirSync(this.options.root)
|
||||
}
|
||||
|
||||
if (this.options.overrides.gameDirectory) {
|
||||
this.options.overrides.gameDirectory = path.resolve(this.options.overrides.gameDirectory)
|
||||
if (!fs.existsSync(this.options.overrides.gameDirectory)) {
|
||||
fs.mkdirSync(this.options.overrides.gameDirectory, { recursive: true })
|
||||
}
|
||||
}
|
||||
|
||||
if (this.options.clientPackage) {
|
||||
this.emit('debug', `[MCLC]: Extracting client package to ${this.options.root}`)
|
||||
await this.handler.extractPackage()
|
||||
|
|
61
package-lock.json
generated
61
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "minecraft-launcher-core",
|
||||
"version": "3.14.4",
|
||||
"version": "3.14.6",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -163,7 +163,8 @@
|
|||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
|
||||
"dev": true
|
||||
},
|
||||
"bcrypt-pbkdf": {
|
||||
"version": "1.0.2",
|
||||
|
@ -178,6 +179,7 @@
|
|||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
|
@ -265,7 +267,8 @@
|
|||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"dev": true
|
||||
},
|
||||
"contains-path": {
|
||||
"version": "0.1.0",
|
||||
|
@ -859,7 +862,7 @@
|
|||
"dependencies": {
|
||||
"combined-stream": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
|
||||
"resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
|
||||
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
|
||||
"requires": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
|
@ -870,7 +873,8 @@
|
|||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
||||
"dev": true
|
||||
},
|
||||
"function-bind": {
|
||||
"version": "1.1.1",
|
||||
|
@ -896,6 +900,7 @@
|
|||
"version": "7.1.3",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
|
||||
"integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
|
@ -1015,6 +1020,7 @@
|
|||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
|
@ -1023,7 +1029,8 @@
|
|||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
|
||||
"dev": true
|
||||
},
|
||||
"inquirer": {
|
||||
"version": "7.1.0",
|
||||
|
@ -1107,11 +1114,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"interpret": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz",
|
||||
"integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ="
|
||||
},
|
||||
"is-arrayish": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
|
||||
|
@ -1312,6 +1314,7 @@
|
|||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
|
@ -1429,6 +1432,7 @@
|
|||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
|
@ -1521,7 +1525,8 @@
|
|||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
|
||||
"dev": true
|
||||
},
|
||||
"path-key": {
|
||||
"version": "2.0.1",
|
||||
|
@ -1532,7 +1537,8 @@
|
|||
"path-parse": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
|
||||
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw=="
|
||||
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
|
||||
"dev": true
|
||||
},
|
||||
"path-type": {
|
||||
"version": "2.0.0",
|
||||
|
@ -1611,14 +1617,6 @@
|
|||
"read-pkg": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"rechoir": {
|
||||
"version": "0.6.2",
|
||||
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
|
||||
"integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=",
|
||||
"requires": {
|
||||
"resolve": "^1.1.6"
|
||||
}
|
||||
},
|
||||
"regexpp": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz",
|
||||
|
@ -1652,14 +1650,6 @@
|
|||
"uuid": "^3.3.2"
|
||||
}
|
||||
},
|
||||
"resolve": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz",
|
||||
"integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==",
|
||||
"requires": {
|
||||
"path-parse": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"resolve-from": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
|
||||
|
@ -1731,16 +1721,6 @@
|
|||
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
|
||||
"dev": true
|
||||
},
|
||||
"shelljs": {
|
||||
"version": "0.8.2",
|
||||
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.2.tgz",
|
||||
"integrity": "sha512-pRXeNrCA2Wd9itwhvLp5LZQvPJ0wU6bcjaTMywHHGX5XWhVN2nzSu7WV0q+oUY7mGK3mgSkDDzP3MgjqdyIgbQ==",
|
||||
"requires": {
|
||||
"glob": "^7.0.0",
|
||||
"interpret": "^1.0.0",
|
||||
"rechoir": "^0.6.2"
|
||||
}
|
||||
},
|
||||
"signal-exit": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz",
|
||||
|
@ -2119,7 +2099,8 @@
|
|||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
||||
"dev": true
|
||||
},
|
||||
"write": {
|
||||
"version": "1.0.3",
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
"adm-zip": "^0.4.13",
|
||||
"checksum": "^0.1.1",
|
||||
"request": "^2.88.0",
|
||||
"shelljs": "^0.8.2",
|
||||
"uuid": "^3.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Add table
Reference in a new issue