mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-12-23 10:23:47 +03:00
[NOISSUE] Nitpicks
This commit is contained in:
parent
d1417e07c8
commit
9ee4f3dda2
4 changed files with 25 additions and 31 deletions
|
@ -2,7 +2,7 @@
|
|||
##### This project is complete for now.
|
||||
[![Build Status](https://travis-ci.com/Pierce01/MinecraftLauncher-core.svg?branch=master)](https://travis-ci.com/Pierce01/MinecraftLauncher-core)
|
||||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
||||
![version](https://img.shields.io/badge/stable_version-3.14.3-blue)
|
||||
![version](https://img.shields.io/badge/stable_version-3.14.4-blue)
|
||||
![badge](https://img.shields.io/badge/ncurses-not_supported-purple)
|
||||
|
||||
MCLC (Minecraft Launcher Core) is a NodeJS solution for launching modded and vanilla Minecraft without having to download and format everything yourself.
|
||||
|
@ -97,7 +97,7 @@ let opts = {
|
|||
natives: "", // native directory path.
|
||||
assetRoot: "",
|
||||
cwd: "", // working directory of the java process.
|
||||
detached: false, // whether or not the client is detached from the parent / launcher.
|
||||
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,
|
||||
maxSockets: 2, // max sockets for downloadAsync.
|
||||
|
|
|
@ -11,7 +11,6 @@ class Handler {
|
|||
constructor (client) {
|
||||
this.client = client
|
||||
this.options = client.options
|
||||
this.version = undefined
|
||||
this.baseRequest = request.defaults({
|
||||
pool: { maxSockets: this.options.overrides.maxSockets || 2 },
|
||||
timeout: this.options.timeout || 10000
|
||||
|
@ -165,7 +164,7 @@ class Handler {
|
|||
if (!fs.existsSync(path.join(subAsset, hash)) || !await this.checkSum(hash, path.join(subAsset, hash))) {
|
||||
await this.downloadAsync(`${this.options.overrides.url.resource}/${subhash}/${hash}`, subAsset, hash,
|
||||
true, 'assets')
|
||||
counter = counter + 1
|
||||
counter++
|
||||
this.client.emit('progress', {
|
||||
type: 'assets',
|
||||
task: counter,
|
||||
|
@ -176,7 +175,7 @@ class Handler {
|
|||
counter = 0
|
||||
|
||||
// Copy assets to legacy if it's an older Minecraft version.
|
||||
if (this.version.assets === 'legacy' || this.version.assets === 'pre-1.6') {
|
||||
if (this.isLegacy()) {
|
||||
const assetDirectory = this.options.overrides.assetRoot || path.join(this.options.root, 'assets')
|
||||
this.client.emit('debug', `[MCLC]: Copying assets over to ${path.join(assetDirectory, 'legacy')}`)
|
||||
|
||||
|
@ -201,7 +200,7 @@ class Handler {
|
|||
if (!fs.existsSync(path.join(assetDirectory, 'legacy', asset))) {
|
||||
fs.copyFileSync(path.join(subAsset, hash), path.join(assetDirectory, 'legacy', asset))
|
||||
}
|
||||
counter = counter + 1
|
||||
counter++
|
||||
this.client.emit('progress', {
|
||||
type: 'assets-copy',
|
||||
task: counter,
|
||||
|
@ -261,7 +260,6 @@ class Handler {
|
|||
})
|
||||
|
||||
await Promise.all(stat.map(async (native) => {
|
||||
// Edge case on some systems where native is undefined and throws an error, this should fix it.
|
||||
if (!native) return
|
||||
const name = native.path.split('/').pop()
|
||||
await this.downloadAsync(native.url, nativeDirectory, name, true, 'natives')
|
||||
|
@ -277,7 +275,7 @@ class Handler {
|
|||
console.warn(e)
|
||||
}
|
||||
shelljs.rm(path.join(nativeDirectory, name))
|
||||
counter = counter + 1
|
||||
counter++
|
||||
this.client.emit('progress', {
|
||||
type: 'natives',
|
||||
task: counter,
|
||||
|
@ -343,7 +341,7 @@ class Handler {
|
|||
|
||||
if (fs.existsSync(path.join(jarPath, name))) {
|
||||
paths.push(`${jarPath}${path.sep}${name}`)
|
||||
counter = counter + 1
|
||||
counter++
|
||||
this.client.emit('progress', { type: 'forge', task: counter, total: forge.libraries.length })
|
||||
return
|
||||
}
|
||||
|
@ -353,7 +351,7 @@ class Handler {
|
|||
if (!download) await this.downloadAsync(`${this.options.overrides.url.fallbackMaven}${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}/${name}`, jarPath, name, true, 'forge')
|
||||
|
||||
paths.push(`${jarPath}${path.sep}${name}`)
|
||||
counter = counter + 1
|
||||
counter++
|
||||
this.client.emit('progress', {
|
||||
type: 'forge',
|
||||
task: counter,
|
||||
|
@ -421,7 +419,7 @@ class Handler {
|
|||
}
|
||||
}
|
||||
|
||||
counter = counter + 1
|
||||
counter++
|
||||
this.client.emit('progress', {
|
||||
type: eventName,
|
||||
task: counter,
|
||||
|
@ -461,16 +459,13 @@ class Handler {
|
|||
return tempArray.join('/')
|
||||
}
|
||||
|
||||
static cleanUp (array) {
|
||||
return new Promise(resolve => {
|
||||
const newArray = []
|
||||
|
||||
for (const classPath in array) {
|
||||
if (newArray.includes(array[classPath])) continue
|
||||
newArray.push(array[classPath])
|
||||
}
|
||||
resolve(newArray)
|
||||
})
|
||||
cleanUp (array) {
|
||||
const newArray = []
|
||||
for (const classPath in array) {
|
||||
if (newArray.includes(array[classPath])) continue
|
||||
newArray.push(array[classPath])
|
||||
}
|
||||
return newArray
|
||||
}
|
||||
|
||||
async getLaunchOptions (modification) {
|
||||
|
@ -480,12 +475,11 @@ class Handler {
|
|||
? type.minecraftArguments.split(' ')
|
||||
: type.arguments.game
|
||||
const assetRoot = this.options.overrides.assetRoot || path.join(this.options.root, 'assets')
|
||||
const assetPath = this.version.assets === 'legacy' ||
|
||||
this.version.assets === 'pre-1.6'
|
||||
const assetPath = this.isLegacy()
|
||||
? path.join(assetRoot, 'legacy')
|
||||
: path.join(assetRoot)
|
||||
|
||||
const minArgs = this.options.overrides.minArgs || (this.version.assets === 'legacy' || this.version.assets === 'pre-1.6') ? 5 : 11
|
||||
const minArgs = this.options.overrides.minArgs || this.isLegacy() ? 5 : 11
|
||||
if (args.length < minArgs) args = args.concat(this.version.minecraftArguments ? this.version.minecraftArguments.split(' ') : this.version.arguments.game)
|
||||
|
||||
this.options.authorization = await Promise.resolve(this.options.authorization)
|
||||
|
@ -544,6 +538,10 @@ class Handler {
|
|||
return opts[this.getOS()]
|
||||
}
|
||||
|
||||
isLegacy () {
|
||||
return this.version.assets === 'legacy' || this.version.assets === 'pre-1.6'
|
||||
}
|
||||
|
||||
getOS () {
|
||||
if (this.options.os) {
|
||||
return this.options.os
|
||||
|
|
|
@ -60,7 +60,6 @@ class MCLCore extends EventEmitter {
|
|||
const directory = this.options.overrides.directory || path.join(this.options.root, 'versions', this.options.version.number)
|
||||
this.options.directory = directory
|
||||
|
||||
// Version JSON for the main launcher folder
|
||||
const versionFile = await this.handler.getVersion()
|
||||
const mcPath = this.options.overrides.minecraftJar || (this.options.version.custom
|
||||
? path.join(this.options.root, 'versions', this.options.version.custom, `${this.options.version.custom}.jar`)
|
||||
|
@ -76,7 +75,6 @@ class MCLCore extends EventEmitter {
|
|||
let custom = null
|
||||
if (this.options.forge) {
|
||||
this.options.forge = path.resolve(this.options.forge)
|
||||
|
||||
this.emit('debug', '[MCLC]: Detected Forge in options, getting dependencies')
|
||||
forge = await this.handler.getForgeDependenciesLegacy()
|
||||
if (forge === false) custom = await this.handler.getForgedWrapped()
|
||||
|
@ -88,7 +86,6 @@ class MCLCore extends EventEmitter {
|
|||
|
||||
const args = []
|
||||
|
||||
// Jvm
|
||||
let jvm = [
|
||||
'-XX:-UseAdaptiveSizePolicy',
|
||||
'-XX:-OmitStackTraceInFastThrow',
|
||||
|
@ -104,7 +101,7 @@ class MCLCore extends EventEmitter {
|
|||
|
||||
if (this.options.customArgs) jvm = jvm.concat(this.options.customArgs)
|
||||
|
||||
const classes = this.options.overrides.classes || await Handler.cleanUp(await this.handler.getClasses(custom))
|
||||
const classes = this.options.overrides.classes || this.handler.cleanUp(await this.handler.getClasses(custom))
|
||||
const classPaths = ['-cp']
|
||||
const separator = this.handler.getOS() === 'windows' ? ';' : ':'
|
||||
this.emit('debug', `[MCLC]: Using ${separator} to separate class paths`)
|
||||
|
@ -122,11 +119,10 @@ class MCLCore extends EventEmitter {
|
|||
classPaths.push(file.mainClass)
|
||||
}
|
||||
|
||||
// Download version's assets
|
||||
this.emit('debug', '[MCLC]: Attempting to download assets')
|
||||
await this.handler.getAssets()
|
||||
|
||||
// Launch options. Thank you Lyrus for the reformat <3
|
||||
// Forge -> Custom -> Vanilla
|
||||
const modification = forge ? forge.forge : null || custom ? custom : null
|
||||
const launchOptions = await this.handler.getLaunchOptions(modification)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "minecraft-launcher-core",
|
||||
"version": "3.14.3",
|
||||
"version": "3.14.4",
|
||||
"description": "Lightweight module that downloads and runs Minecraft using javascript / NodeJS",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
|
|
Loading…
Add table
Reference in a new issue