From 4af8329193a83fc488834c695115cd12b3d05eba Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Sun, 9 Aug 2020 15:55:43 +0200 Subject: [PATCH] added all option to DownloadMods --- .../modpacktools/commands/DownloadMods.kt | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ley/anvil/modpacktools/commands/DownloadMods.kt b/src/main/kotlin/ley/anvil/modpacktools/commands/DownloadMods.kt index 4e443f8..f198269 100644 --- a/src/main/kotlin/ley/anvil/modpacktools/commands/DownloadMods.kt +++ b/src/main/kotlin/ley/anvil/modpacktools/commands/DownloadMods.kt @@ -33,23 +33,39 @@ object DownloadMods : ICommand { parser.addArgument("-f", "--force") .action(storeTrue()) .help("if true, mods that are already in the download folder will be downloaded again") + + parser.addArgument("-a", "--all") + .action(storeTrue()) + .help("Downloads not only mods but everything with a dir installer") + parser } override fun execute(args: Namespace): CommandReturn { val json = MPJH.asWrapper val fileList = mutableListOf() - for (rel in json!!.defaultVersion!!.getRelations(arrayOf("client"), arrayOf("mod"))!!) - if (rel.hasFile()) + for(rel in json!!.defaultVersion!!.getRelations(arrayOf("client"), if(args.getBoolean("all")) null else arrayOf("mod"))!!) //TODO only client? what if someone wants a server? + if(rel.hasFile()) fileList.add(rel.file.get()) downloadFiles( fileList.stream() .filter {it.isURL} - .filter {it.installer == "internal.dir:mods"} + .filter { + val (installer, dir) = it.installer.split(':') + + installer == "internal.dir" && (args.getBoolean("all") || dir == "mods") + } .collect(toMap( {URL(it.link)}, - {args.get("dir")}, + { + val dir = it.installer.split(':').last() + + if(args.getBoolean("all")) + File(args.get("dir"), dir) + else + args.get("dir") + }, {_: File, f: File -> f} )), {r: DownloadFileTask.Return ->