mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-11-22 04:06:21 +03:00
Merge branch 'master' of https://github.com/artegoser/pimi-launcher-core
This commit is contained in:
commit
4a6c340180
2 changed files with 37 additions and 62 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.com/Pierce01/MinecraftLauncher-core.svg?branch=master)](https://travis-ci.com/Pierce01/MinecraftLauncher-core)
|
[![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)
|
[![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.17.0-blue)
|
![version](https://img.shields.io/badge/stable_version-3.17.1-blue)
|
||||||
![badge](https://img.shields.io/badge/ncurses-not_supported-purple)
|
![badge](https://img.shields.io/badge/ncurses-not_supported-purple)
|
||||||
|
|
||||||
PiMi (Minecraft Launcher Core) is a NodeJS solution for launching modded and vanilla Minecraft without having to download and format everything yourself.
|
PiMi (Minecraft Launcher Core) is a NodeJS solution for launching modded and vanilla Minecraft without having to download and format everything yourself.
|
||||||
|
|
|
@ -697,74 +697,49 @@ class Handler {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadToDirectory(directory, libraries, eventName) {
|
async downloadToDirectory (directory, libraries, eventName) {
|
||||||
const libs = [];
|
const libs = []
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(libraries.map(async library => {
|
||||||
libraries.map(async (library) => {
|
if (!library) return
|
||||||
if (!library) return;
|
if (this.parseRule(library)) return
|
||||||
if (this.parseRule(library)) return;
|
const lib = library.name.split(':')
|
||||||
const lib = library.name.split(":");
|
|
||||||
|
|
||||||
let jarPath;
|
let jarPath
|
||||||
let name;
|
let name
|
||||||
if (
|
if (library.downloads && library.downloads.artifact && library.downloads.artifact.path) {
|
||||||
library.downloads &&
|
name = library.downloads.artifact.path.split('/')[library.downloads.artifact.path.split('/').length - 1]
|
||||||
library.downloads.artifact &&
|
jarPath = path.join(directory, this.popString(library.downloads.artifact.path))
|
||||||
library.downloads.artifact.path
|
} else {
|
||||||
) {
|
name = `${lib[1]}-${lib[2]}${lib[3] ? '-' + lib[3] : ''}.jar`
|
||||||
name =
|
jarPath = path.join(directory, `${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}`)
|
||||||
library.downloads.artifact.path.split("/")[
|
}
|
||||||
library.downloads.artifact.path.split("/").length - 1
|
|
||||||
];
|
const downloadLibrary = async library => {
|
||||||
jarPath = path.join(
|
if (library.url) {
|
||||||
directory,
|
const url = `${library.url}${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}/${name}`
|
||||||
this.popString(library.downloads.artifact.path)
|
await this.downloadAsync(url, jarPath, name, true, eventName)
|
||||||
);
|
} else if (library.downloads && library.downloads.artifact) {
|
||||||
} else {
|
await this.downloadAsync(library.downloads.artifact.url, jarPath, name, true, eventName)
|
||||||
name = `${lib[1]}-${lib[2]}${lib[3] ? "-" + lib[3] : ""}.jar`;
|
|
||||||
jarPath = path.join(
|
|
||||||
directory,
|
|
||||||
`${lib[0].replace(/\./g, "/")}/${lib[1]}/${lib[2]}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (!fs.existsSync(path.join(jarPath, name))) downloadLibrary(library)
|
||||||
!fs.existsSync(path.join(jarPath, name)) ||
|
else if (library.downloads && library.downloads.artifact) {
|
||||||
!this.checkSum(
|
if (!this.checkSum(library.downloads.artifact.sha1, path.join(jarPath, name))) downloadLibrary(library)
|
||||||
library.downloads.artifact.sha1,
|
}
|
||||||
path.join(jarPath, name)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
// Simple lib support, forgot which addon needed this but here you go, Mr special.
|
|
||||||
if (library.url) {
|
|
||||||
const url = `${library.url}${lib[0].replace(/\./g, "/")}/${
|
|
||||||
lib[1]
|
|
||||||
}/${lib[2]}/${name}`;
|
|
||||||
await this.downloadAsync(url, jarPath, name, true, eventName);
|
|
||||||
} else if (library.downloads && library.downloads.artifact) {
|
|
||||||
await this.downloadAsync(
|
|
||||||
library.downloads.artifact.url,
|
|
||||||
jarPath,
|
|
||||||
name,
|
|
||||||
true,
|
|
||||||
eventName
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
counter++;
|
counter++
|
||||||
this.client.emit("progress", {
|
this.client.emit('progress', {
|
||||||
type: eventName,
|
type: eventName,
|
||||||
task: counter,
|
task: counter,
|
||||||
total: libraries.length,
|
total: libraries.length
|
||||||
});
|
|
||||||
libs.push(`${jarPath}${path.sep}${name}`);
|
|
||||||
})
|
})
|
||||||
);
|
libs.push(`${jarPath}${path.sep}${name}`)
|
||||||
counter = 0;
|
}))
|
||||||
|
counter = 0
|
||||||
|
|
||||||
return libs;
|
return libs
|
||||||
}
|
}
|
||||||
|
|
||||||
async getClasses(classJson) {
|
async getClasses(classJson) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue