From 6ca014dbba7b68b5c0645bc7e462c985c60611e0 Mon Sep 17 00:00:00 2001 From: HerozDotExe Date: Sat, 17 Jun 2023 19:23:19 +0200 Subject: [PATCH 1/3] Fix no artifact property when downloading a library --- components/handler.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/components/handler.js b/components/handler.js index 1acb92b..21209a5 100644 --- a/components/handler.js +++ b/components/handler.js @@ -509,7 +509,8 @@ class Handler { jarPath = path.join(directory, `${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}`) } - if (!fs.existsSync(path.join(jarPath, name)) || !this.checkSum(library.downloads.artifact.sha1, path.join(jarPath, name))) { + // Fix no artifact property when downloading a library + if (!fs.existsSync(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}` @@ -519,6 +520,18 @@ class Handler { } } + if(library.downloads){ + if(!this.checkSum(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++ this.client.emit('progress', { type: eventName, From 5e004db47cfd88627786966e6bd445022e96f0e1 Mon Sep 17 00:00:00 2001 From: Pierce Date: Sun, 18 Jun 2023 17:37:33 -0700 Subject: [PATCH 2/3] extract library download logic into its own function Enforcing the DRY principle here. --- components/handler.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/components/handler.js b/components/handler.js index 21209a5..94be656 100644 --- a/components/handler.js +++ b/components/handler.js @@ -509,9 +509,7 @@ class Handler { jarPath = path.join(directory, `${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}`) } - // Fix no artifact property when downloading a library - if (!fs.existsSync(path.join(jarPath, name))) { - // Simple lib support, forgot which addon needed this but here you go, Mr special. + const downloadLibrary = async library => { if (library.url) { const url = `${library.url}${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}/${name}` await this.downloadAsync(url, jarPath, name, true, eventName) @@ -520,16 +518,9 @@ class Handler { } } - if(library.downloads){ - if(!this.checkSum(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) - } - } + if (!fs.existsSync(path.join(jarPath, name))) downloadLibrary(library) + else if (library.downloads && library.downloads.artifact) { + if (!this.checkSum(library.downloads.artifact.sha1, path.join(jarPath, name))) downloadLibrary(library) } counter++ From bf202c3a300d0666e077b36a70dde76ce76b2fd3 Mon Sep 17 00:00:00 2001 From: Pierce Date: Sun, 18 Jun 2023 17:40:16 -0700 Subject: [PATCH 3/3] NPM bump, hotfix --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a33453e..79363bc 100644 --- a/README.md +++ b/README.md @@ -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.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) MCLC (Minecraft Launcher Core) is a NodeJS solution for launching modded and vanilla Minecraft without having to download and format everything yourself. diff --git a/package.json b/package.json index fe34150..236e380 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minecraft-launcher-core", - "version": "3.17.0", + "version": "3.17.1", "description": "Lightweight module that downloads and runs Minecraft using javascript / NodeJS", "main": "index.js", "dependencies": {