From b3cd41f215164b3a12af34dd36384b729c86f4f1 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Tue, 28 Jul 2020 00:02:29 +0200 Subject: [PATCH] cleanup --- .../modpacktools/commands/CreateModlist.kt | 1 - .../anvil/modpacktools/util/ASConverter.kt | 76 ------------------- .../modpacktools/util/ManifestLinksPair.kt | 11 --- .../modpacktools/util/manifest/ASConverter.kt | 75 ++++++++++++++++++ .../util/manifest/ManifestLinksPair.kt | 9 +++ 5 files changed, 84 insertions(+), 88 deletions(-) delete mode 100644 src/main/kotlin/ley/anvil/modpacktools/util/ASConverter.kt delete mode 100644 src/main/kotlin/ley/anvil/modpacktools/util/ManifestLinksPair.kt create mode 100644 src/main/kotlin/ley/anvil/modpacktools/util/manifest/ASConverter.kt create mode 100644 src/main/kotlin/ley/anvil/modpacktools/util/manifest/ManifestLinksPair.kt diff --git a/src/main/kotlin/ley/anvil/modpacktools/commands/CreateModlist.kt b/src/main/kotlin/ley/anvil/modpacktools/commands/CreateModlist.kt index c89c488..c08b4a8 100644 --- a/src/main/kotlin/ley/anvil/modpacktools/commands/CreateModlist.kt +++ b/src/main/kotlin/ley/anvil/modpacktools/commands/CreateModlist.kt @@ -2,7 +2,6 @@ package ley.anvil.modpacktools.commands import j2html.TagCreator.* import j2html.utils.CSSMin.compressCss -import ley.anvil.addonscript.maven.ArtifactDestination import ley.anvil.addonscript.wrapper.ASWrapper import ley.anvil.addonscript.wrapper.ArtifactDestination import ley.anvil.addonscript.wrapper.MetaData diff --git a/src/main/kotlin/ley/anvil/modpacktools/util/ASConverter.kt b/src/main/kotlin/ley/anvil/modpacktools/util/ASConverter.kt deleted file mode 100644 index b5e35db..0000000 --- a/src/main/kotlin/ley/anvil/modpacktools/util/ASConverter.kt +++ /dev/null @@ -1,76 +0,0 @@ -package ley.anvil.modpacktools.util - -import ley.anvil.addonscript.curse.ManifestJSON -import ley.anvil.addonscript.wrapper.ASWrapper - -fun convertAStoManifest(addonscript: ASWrapper): ManifestLinksPair { - var ml = ManifestLinksPair() - var ver = addonscript.defaultVersion - var manifest = ManifestJSON() - - var mcv = ver.version?.mcversion!![0] - manifest.minecraft = ManifestJSON.Minecraft() - manifest.minecraft.version = mcv - manifest.minecraft.modLoaders = mutableListOf() - manifest.files = mutableListOf() - - manifest.manifestType = "minecraftModpack" - manifest.manifestVersion = 1 - manifest.name = addonscript.json.meta!!.name - if (manifest.name == null) - manifest.name = addonscript.json.id - manifest.version = ver.versionName - manifest.author = addonscript.json!!.meta!!.contributors[0].name - - - for (rel in ver.getRelations(arrayOf("client"), null)) { - if (rel.isModloader) { - if (rel.relation.id == "forge") { - var forge = ManifestJSON.Modloader() - forge.primary = true - forge.id = "forge-" + rel.versions.latestKnown - manifest.minecraft.modLoaders.add(forge) - } else { - println("Curse only allows Forge as a modloader. " + rel.relation.id + " is not allowed!") - } - } else if (rel.hasFile()) { - var file = rel.file - if (file.file.installer == "internal.jar") { - println("internal.jar is not supportet on Curse") - continue - } else if (file.isArtifact) { - var art = file.artifact - if (art.isCurseforge) { - var f = ManifestJSON.File() - f.fileID = art.fileID - f.projectID = art.projectID - f.required = rel.options.contains("required") - manifest.files.add(f); - } - } else if (rel.options.contains("required")) { - ml.links.put(file.get(), file.file.installer) - } - } - } - - for (file in ver.getFiles(arrayOf("client", "required"), null)) { - if (file.file.installer == "internal.jar") { - println("internal.jar is not supportet on Curse") - continue - } else if (file.isArtifact) { - var art = file.artifact - if (art.isCurseforge) { - var f = ManifestJSON.File() - f.fileID = art.fileID - f.projectID = art.projectID - f.required = true - manifest.files.add(f); - } - } else { - ml.links.put(file.get(), file.file.installer) - } - } - ml.manifest = manifest - - return ml -} \ No newline at end of file diff --git a/src/main/kotlin/ley/anvil/modpacktools/util/ManifestLinksPair.kt b/src/main/kotlin/ley/anvil/modpacktools/util/ManifestLinksPair.kt deleted file mode 100644 index 49a4d9a..0000000 --- a/src/main/kotlin/ley/anvil/modpacktools/util/ManifestLinksPair.kt +++ /dev/null @@ -1,11 +0,0 @@ -package ley.anvil.modpacktools.util - -import ley.anvil.addonscript.curse.ManifestJSON -import ley.anvil.addonscript.wrapper.FileOrLink - -class ManifestLinksPair { - - var manifest: ManifestJSON? = null - var links: MutableMap = HashMap() - -} \ No newline at end of file diff --git a/src/main/kotlin/ley/anvil/modpacktools/util/manifest/ASConverter.kt b/src/main/kotlin/ley/anvil/modpacktools/util/manifest/ASConverter.kt new file mode 100644 index 0000000..e4d7ad3 --- /dev/null +++ b/src/main/kotlin/ley/anvil/modpacktools/util/manifest/ASConverter.kt @@ -0,0 +1,75 @@ +package ley.anvil.modpacktools.util.manifest + +import ley.anvil.addonscript.curse.ManifestJSON +import ley.anvil.addonscript.wrapper.ASWrapper + +fun convertAStoManifest(addonscript: ASWrapper): ManifestLinksPair { + val ml = ManifestLinksPair() + val ver = addonscript.defaultVersion + val manifest = ManifestJSON() + + val mcv = ver.version!!.mcversion[0] + manifest.minecraft = ManifestJSON.Minecraft() + manifest.minecraft.version = mcv + manifest.minecraft.modLoaders = mutableListOf() + manifest.files = mutableListOf() + + manifest.manifestType = "minecraftModpack" + manifest.manifestVersion = 1 + manifest.name = addonscript.json.meta!!.name ?: addonscript.json.id + manifest.version = ver.versionName + manifest.author = addonscript.json!!.meta!!.contributors[0].name + + + for(rel in ver.getRelations(arrayOf("client"), null)) { + if(rel.isModloader) { + if(rel.relation.id == "forge") { + val forge = ManifestJSON.Modloader() + forge.primary = true + forge.id = "forge-" + rel.versions.latestKnown + manifest.minecraft.modLoaders.add(forge) + } else { + println("Curse only allows Forge as a modloader. ${rel.relation.id} is not allowed!") + } + } else if(rel.hasFile()) { + val file = rel.file + //TODO deduplicate this + if(file.file.installer == "internal.jar") { + println("internal.jar is not supported on Curse") + continue + } else if(file.isArtifact) { + val art = file.artifact + if(art.isCurseforge) { + val f = ManifestJSON.File() + f.fileID = art.fileID + f.projectID = art.projectID + f.required = rel.options.contains("required") + manifest.files.add(f) + } + } else if(rel.options.contains("required")) { + ml.links[file.get()] = file.file.installer + } + } + } + + for(file in ver.getFiles(arrayOf("client", "required"), null)) { + if(file.file.installer == "internal.jar") { + println("internal.jar is not supported on Curse") + continue + } else if(file.isArtifact) { + val art = file.artifact + if(art.isCurseforge) { + val f = ManifestJSON.File() + f.fileID = art.fileID + f.projectID = art.projectID + f.required = true + manifest.files.add(f) + } + } else { + ml.links[file.get()] = file.file.installer + } + } + ml.manifest = manifest + + return ml +} \ No newline at end of file diff --git a/src/main/kotlin/ley/anvil/modpacktools/util/manifest/ManifestLinksPair.kt b/src/main/kotlin/ley/anvil/modpacktools/util/manifest/ManifestLinksPair.kt new file mode 100644 index 0000000..02d74dd --- /dev/null +++ b/src/main/kotlin/ley/anvil/modpacktools/util/manifest/ManifestLinksPair.kt @@ -0,0 +1,9 @@ +package ley.anvil.modpacktools.util.manifest + +import ley.anvil.addonscript.curse.ManifestJSON +import ley.anvil.addonscript.wrapper.FileOrLink + +data class ManifestLinksPair ( + var manifest: ManifestJSON? = null, + var links: MutableMap = mutableMapOf() +) \ No newline at end of file