4
0
Fork 0
mirror of https://github.com/Anvilcraft/modpacktools synced 2024-09-30 04:59:05 +02:00

fix tilera's code

This commit is contained in:
LordMZTE 2020-07-26 16:59:31 +02:00
parent 86c7c7d67d
commit 9d3c82fe37
2 changed files with 9 additions and 13 deletions

View file

@ -97,19 +97,16 @@ object CreateModlist : ICommand {
private fun getMods(): List<MetaData> {
println("Getting mods... this may take a while (TODO)")
val asJson = Main.MPJH.asWrapper
val mods = ArrayList<MetaData>()
val toGet = ArrayList<String>()
val mods = mutableListOf<MetaData>()
val toGet = mutableListOf<String>()
for(rel in asJson!!.defaultVersion.getRelations(arrayOf("client"), null)) {
if (rel.hasLocalMeta()) {
println("got info for file ${rel.localMeta.name}")
if (rel.hasLocalMeta())
mods.add(rel.localMeta)
}
else if (rel.hasFile() && rel.file.isArtifact)
toGet.add(rel.file.artifact)
}
val metaMap = asJson.repositories.getMeta(toGet.toArray(emptyArray()))
mods.addAll(metaMap.values)
mods.addAll(asJson.repositories.getMeta(toGet.toTypedArray()).values)
return mods.sortedBy {m -> m.name?.toLowerCase() }
}

View file

@ -26,17 +26,16 @@ object DownloadMods : ICommand {
val json = MPJH.asWrapper
val filelist = ArrayList<ASWrapper.FileWrapper>()
for (rel in json?.defaultVersion?.getRelations(arrayOf("client"), "mod")!!) {
val fileList = mutableListOf<ASWrapper.FileWrapper>()
for (rel in json!!.defaultVersion!!.getRelations(arrayOf("client"), "mod")!!)
if (rel.hasFile())
filelist.add(rel.file)
}
fileList.add(rel.file)
FileDownloader(
filelist.stream()
fileList.stream()
.filter {it.isURL}
.collect(toMap<ASWrapper.FileWrapper, URL, File>(
{URL(it.link)}, //TODO Get the link using Multithreadding
{URL(it.link)}, //TODO Get the link using Multithreading
{File(args[1], Paths.get(URL(it.link).path).fileName.toString())},
{_: File, f: File -> f}
)),