Skip to content

Commit 665c53d

Browse files
committed
fixed simplelauncher for pre1.13
1 parent c567423 commit 665c53d

File tree

6 files changed

+201
-95
lines changed

6 files changed

+201
-95
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simplelauncher",
3-
"version": "0.3.18",
3+
"version": "0.3.19",
44
"description": "Launcher for SimpleClient",
55
"main": "src/main.js",
66
"scripts": {
@@ -30,6 +30,7 @@
3030
"dependencies": {
3131
"app-root-path": "^3.1.0",
3232
"child_process": "^1.0.2",
33+
"crypto": "^1.0.1",
3334
"electron-is-dev": "^2.0.0",
3435
"os": "^0.1.2",
3536
"path": "^0.12.7"

src/download/fabricdownloader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ const downloadFabric = (version, meta, callback) => {
2020
const fabricDir = join(getMinecraftDir(), 'versions', fabric)
2121
if (existsSync(join(fabricDir, `${fabric}.json`))) downloadJar(version, meta, callback)
2222
else {
23-
fetch('https://meta.fabricmc.net/v2/versions/installer').then(fabricInstallerResponse => {
23+
var fabricInstallerUrl = 'https://meta.fabricmc.net/v2/versions/installer'
24+
if (version.overrides.fabric_installer_url) fabricInstallerUrl = version.overrides.fabric_installer_url
25+
fetch(fabricInstallerUrl).then(fabricInstallerResponse => {
2426
if (fabricInstallerResponse) {
2527
fabricInstallerResponse.json().then(fabricInstallerJson => {
2628
const fabricInstallerFile = join(getDirectory(), 'versions', version.id, `fabric-installer-${fabricInstallerJson[0].version}.jar`)

src/download/javadownloader.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const downloadJava = (version, callback) => {
4242
getJavaDownloadsUrl(version, url => {
4343
if (url) {
4444
getJavaDownloads(url, downloads => {
45-
console.log(downloads)
4645
downloads = downloads.map(download => [download[1].downloads.raw.url, join(dir, download[0])])
4746
downloadFilesAsync(downloads, undefined, log, callback)
4847
})

src/download/librarydownloader.js

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,55 @@
11
const { join } = require("path")
22
const { downloadFilesAsync } = require("./downloader")
33
const { getMinecraftDir } = require("../util")
4+
const { platform } = require("os")
5+
const { getJavaPath } = require("./javadownloader")
6+
const { spawn } = require("child_process")
7+
const { env, stdout, stderr } = require("process")
8+
const { existsSync, mkdirSync } = require("fs")
49

510
const log = (...data) => console.log('[Library Download] ' + data)
611

7-
const downloadLibraries = (meta, callback) => {
12+
const collectLibraries = (meta, checkRule) => {
813
const dir = join(getMinecraftDir(), 'libraries')
9-
const libraries = meta.libraries.map(library => [library.downloads.artifact.url, join(dir, library.downloads.artifact.path)])
10-
downloadFilesAsync(libraries, undefined, log, callback)
14+
const allowedLibraries = meta.libraries.filter(library => library.rules ? library.rules.every(checkRule) : true)
15+
const libraries = []
16+
allowedLibraries.forEach(library => {
17+
if (library.downloads.classifiers) {
18+
const classifier = library.natives[platform() == 'win32' ? 'windows' : 'linux']
19+
const download = library.downloads.classifiers[classifier]
20+
libraries.push([download.url, join(dir, download.path)])
21+
} else if (library.downloads.artifact) libraries.push([library.downloads.artifact.url, join(dir, library.downloads.artifact.path)])
22+
})
23+
return libraries
1124
}
1225

13-
module.exports = {downloadLibraries}
26+
const collectNatives = (meta, checkRule) => {
27+
const dir = join(getMinecraftDir(), 'libraries')
28+
const allowedLibraries = meta.libraries.filter(library => library.rules ? library.rules.every(checkRule) : true)
29+
const natives = []
30+
allowedLibraries.forEach(library => {
31+
if (library.downloads.classifiers) {
32+
const classifier = library.natives[platform() == 'win32' ? 'windows' : 'linux']
33+
const download = library.downloads.classifiers[classifier]
34+
natives.push(join(dir, download.path))
35+
}
36+
})
37+
return natives
38+
}
39+
40+
const extractNatives = (meta, natives, nativesDirectory, separator, callback) => {
41+
if (!existsSync(nativesDirectory)) mkdirSync(nativesDirectory, {recursive: true})
42+
if (natives.length == 0) callback(true)
43+
else {
44+
const native = natives.shift()
45+
spawn(join(getJavaPath(meta.javaVersion.component), 'bin', 'jar'), ['xf', native], {
46+
cwd: nativesDirectory,
47+
env: {PATH: env.PATH + separator + getJavaPath(meta.javaVersion.component)}
48+
}).on('exit', status => {
49+
if (status == 0) extractNatives(meta, natives, nativesDirectory, separator, callback)
50+
else callback(false)
51+
})
52+
}
53+
}
54+
55+
module.exports = {collectLibraries, collectNatives, extractNatives}

src/gui/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
document.getElementById('launch').innerText = 'Downloading Fabric Loader'
4343
} else if (status == 'downloading_libraries') {
4444
document.getElementById('launch').innerText = 'Downloading Libraries'
45+
} else if (status == 'extracting_natives') {
46+
document.getElementById('launch').innerText = 'Extracting Natives'
4547
} else if (status == 'downloading_assets') {
4648
document.getElementById('launch').innerText = 'Downloading Assets'
4749
} else if (status == 'downloading_mods') {

0 commit comments

Comments
 (0)