From 0328871fa71f3256bfbee06aa0e95a8a4a0df319 Mon Sep 17 00:00:00 2001 From: Griefed Date: Thu, 18 Jul 2024 21:53:44 +0200 Subject: [PATCH] docs: Add and expand existing docs in the API --- .../api/config/ConfigCheck.kt | 74 +++++++++++++++++++ .../api/config/ConfigurationHandler.kt | 2 +- .../api/config/InclusionSpecification.kt | 16 ++++ .../api/config/ModpackSource.kt | 3 + .../api/config/PackConfig.kt | 10 ++- .../api/modscanning/FabricScanner.kt | 3 +- .../api/modscanning/ForgeTomlScanner.kt | 2 +- .../api/modscanning/NeoForgeTomlScanner.kt | 25 +++++++ .../api/serverpack/ServerPackGeneration.kt | 27 +++++++ .../api/serverpack/ServerPackHandler.kt | 3 +- .../api/serverpack/ServerPackManifest.kt | 16 +++- .../api/utilities/SPCListeners.kt | 51 ++++++++++++- .../common/SemanticVersionComparator.kt | 19 +++++ .../api/utilities/common/UtilityEnums.kt | 19 +++++ .../versionmeta/neoforge/NeoForgeInstance.kt | 19 +++++ .../api/ConfigurationHandlerTest.kt | 6 +- .../serverpackcreator/api/PackConfigTest.kt | 3 +- .../app/cli/ConfigurationEditor.kt | 6 +- .../app/gui/window/configs/ConfigEditor.kt | 2 +- .../gui/window/configs/TabbedConfigsTab.kt | 6 +- 20 files changed, 286 insertions(+), 26 deletions(-) diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/ConfigCheck.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/ConfigCheck.kt index 91bb193d5..45292a36e 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/ConfigCheck.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/ConfigCheck.kt @@ -28,66 +28,135 @@ import de.griefed.serverpackcreator.api.utilities.common.concatenate */ class ConfigCheck { + /** + * List of errors encountered during the config checks of the configuration. + */ val configErrors: MutableList = mutableListOf() + + /** + * Whether the config checks passed. Only true if all checks passed. + */ val configChecksPassed: Boolean get() { return configErrors.isEmpty() } + /** + * List of errors encountered during the modpack checks of the configuration. + */ val modpackErrors: MutableList = mutableListOf() + + /*** + * Whether the modpack checks passed. Only true if all checks passed. + */ val modpackChecksPassed: Boolean get() { return modpackErrors.isEmpty() } + /** + * List of errors encountered during the inclusion checks of the configuration. + */ val inclusionErrors: MutableList = mutableListOf() + + /** + * Whether the inclusion checks passed. Only true if all checks passed. + */ val inclusionsChecksPassed: Boolean get() { return inclusionErrors.isEmpty() } + /** + * List of errors encountered during the Minecraft-version checks of the configuration. + */ val minecraftVersionErrors: MutableList = mutableListOf() + + /** + * Whether the Minecraft-version checks passed. Only true if all checks passed. + */ val minecraftVersionChecksPassed: Boolean get() { return minecraftVersionErrors.isEmpty() } + /** + * List of errors encountered during the modloader checks of the configuration. + */ val modloaderErrors: MutableList = mutableListOf() + + /** + * Whether the modloader checks passed. Only true if all checks passed. + */ val modloaderChecksPassed: Boolean get() { return modloaderErrors.isEmpty() } + /** + * List of errors encountered during the modloader-version checks of the configuration. + */ val modloaderVersionErrors: MutableList = mutableListOf() + + /** + * Whether the modloader-version checks passed. Only true if all checks passed. + */ val modloaderVersionChecksPassed: Boolean get() { return modloaderVersionErrors.isEmpty() } + /** + * List of errors encountered during the server-icon checks of the configuration. + */ val serverIconErrors: MutableList = mutableListOf() + + /** + * Whether the server-icon checks passed. Only true if all checks passed. + */ val serverIconChecksPassed: Boolean get() { return serverIconErrors.isEmpty() } + /** + * List of errors encountered during the server.properties checks of the configuration. + */ val serverPropertiesErrors: MutableList = mutableListOf() + + /** + * Whether the server.properties checks passed. Only true if all checks passed. + */ val serverPropertiesChecksPassed: Boolean get() { return serverPropertiesErrors.isEmpty() } + /** + * List of errors encountered in plugin-provided checks of the configuration. + */ val pluginsErrors: MutableList = mutableListOf() + + /** + * Whether all plugin-provided checks passed. Only true if all passed. + */ val pluginsChecksPassed: Boolean get() { return pluginsErrors.isEmpty() } + /** + * List of errors which didn't fit any of the other categories. + */ val otherErrors: MutableList = mutableListOf() val otherChecksPassed: Boolean get() { return otherErrors.isEmpty() } + /** + * List of all errors encountered during the check of this configuration. + */ val encounteredErrors: MutableList get() { return concatenate( @@ -103,6 +172,11 @@ class ConfigCheck { otherErrors ).toMutableList() } + + /** + * Whether all checks were passed for this configuration. Only true if every single check, including those of any + * installed plugins, passed. + */ val allChecksPassed: Boolean get() { return encounteredErrors.isEmpty() diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/ConfigurationHandler.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/ConfigurationHandler.kt index 92e028f9e..e3c08e2fe 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/ConfigurationHandler.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/ConfigurationHandler.kt @@ -108,7 +108,7 @@ class ConfigurationHandler( */ fun checkConfiguration(configFile: File, packConfig: PackConfig = PackConfig(), configCheck: ConfigCheck = ConfigCheck(), quietCheck: Boolean = false): ConfigCheck { try { - val fileConf = PackConfig(utilities, configFile) + val fileConf = PackConfig(configFile) packConfig.setClientMods(fileConf.clientMods) packConfig.setInclusions(fileConf.inclusions) packConfig.setModsWhitelist(fileConf.modsWhitelist) diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/InclusionSpecification.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/InclusionSpecification.kt index 2da9ee605..6c54f3cb1 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/InclusionSpecification.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/InclusionSpecification.kt @@ -45,22 +45,38 @@ class InclusionSpecification( var exclusionFilter: String? = null ) { + /** + * Whether this inclusion-spec has an Inclusion-Filter present. + */ fun hasInclusionFilter(): Boolean { return inclusionFilter != null && inclusionFilter!!.isNotBlank() } + /** + * Whether this inclusion-spec has an Exclusion-Filter present. + */ fun hasExclusionFilter(): Boolean { return exclusionFilter != null && exclusionFilter!!.isNotBlank() } + /** + * Whether this inclusion-spec has a destination in the server-pack-to-be set. + */ fun hasDestination(): Boolean { return !destination.isNullOrBlank() } + /** + * Whether this inclusion-spec is a global filter to be applied to every inclusion. + * A global filter requires the source to be empty and/or blank and an inclusion- or exclusion-filter to be set. + */ fun isGlobalFilter(): Boolean { return (source.isBlank() && hasInclusionFilter()) || (source.isBlank() && hasExclusionFilter()) } + /** + * Get this inclusion-spec as a hashmap. + */ fun asHashMap(): HashMap { val map = HashMap() map["source"] = source diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/ModpackSource.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/ModpackSource.kt index 6a3813b6b..2eb7f1481 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/ModpackSource.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/ModpackSource.kt @@ -19,6 +19,9 @@ */ package de.griefed.serverpackcreator.api.config +/** + * Source-indicator for where the modpack came from. Entries are self-explanatory. + */ enum class ModpackSource { ZIP, MODRINTH, CURSEFORGE, DIRECTORY } \ No newline at end of file diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/PackConfig.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/PackConfig.kt index 8ad4972a1..e1c46ca47 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/PackConfig.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/config/PackConfig.kt @@ -27,8 +27,8 @@ import com.electronwill.nightconfig.core.io.WritingMode import com.electronwill.nightconfig.toml.TomlFormat import com.fasterxml.jackson.databind.JsonNode import de.griefed.serverpackcreator.api.ApiProperties +import de.griefed.serverpackcreator.api.ApiWrapper import de.griefed.serverpackcreator.api.utilities.common.StringUtilities -import de.griefed.serverpackcreator.api.utilities.common.Utilities import org.apache.logging.log4j.kotlin.cachedLoggerOf import java.io.File import java.io.FileNotFoundException @@ -314,7 +314,6 @@ open class PackConfig() { /** * Create a new configuration model from a config file. * - * @param utilities Instance of our SPC utilities. * @param configFile Configuration file to load. * @throws FileNotFoundException if the specified file can not be found. * @throws NoFormatFoundException if the configuration format could not be determined by @@ -323,7 +322,7 @@ open class PackConfig() { */ @Throws(NoFormatFoundException::class, FileNotFoundException::class) @Suppress("UNCHECKED_CAST") - constructor(utilities: Utilities, configFile: File) : this() { + constructor(configFile: File) : this() { if (!configFile.exists()) { throw FileNotFoundException("Couldn't find file: $configFile") } @@ -435,8 +434,11 @@ open class PackConfig() { config.set(inclusionsKey, newInclusionsList) } + /** + * Save this configuration to disk. + */ @Suppress("DuplicatedCode") - fun save(destination: File, apiProperties: ApiProperties): PackConfig { + fun save(destination: File, apiProperties: ApiProperties = ApiWrapper.api().apiProperties): PackConfig { val conf = TomlFormat.instance().createConfig() conf.setComment(configVersionKey, configVersionComment) diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/modscanning/FabricScanner.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/modscanning/FabricScanner.kt index 32c6eaa65..0c908dbd3 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/modscanning/FabricScanner.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/modscanning/FabricScanner.kt @@ -45,8 +45,7 @@ class FabricScanner( private val client = "client" private val environment = "environment" private val depends = "depends" - - val dependencyExclusions: Regex + private val dependencyExclusions: Regex get() = "(fabric|fabricloader|java|minecraft)".toRegex() /** diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/modscanning/ForgeTomlScanner.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/modscanning/ForgeTomlScanner.kt index a537961ab..4110438f0 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/modscanning/ForgeTomlScanner.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/modscanning/ForgeTomlScanner.kt @@ -29,7 +29,7 @@ import java.util.* import java.util.jar.JarFile /** - * `mods.toml`-based scanning of Fabric-Minecraft mods for Minecraft 1.16.5 and newer. + * `mods.toml`-based scanning of Forge-Minecraft mods for Minecraft 1.16.5 and newer. * * @param tomlParser To parse .toml-files. * @Griefed diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/modscanning/NeoForgeTomlScanner.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/modscanning/NeoForgeTomlScanner.kt index 75f4fbeb1..1bb48d13f 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/modscanning/NeoForgeTomlScanner.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/modscanning/NeoForgeTomlScanner.kt @@ -1,7 +1,32 @@ +/* Copyright (C) 2024 Griefed + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * The full license can be found at https:github.com/Griefed/ServerPackCreator/blob/main/LICENSE + */ package de.griefed.serverpackcreator.api.modscanning import com.electronwill.nightconfig.toml.TomlParser +/** + * `neoforge.mods.toml`-based scanning of NeoForge-Minecraft mods for Minecraft 1.16.5 and newer. + * + * @param tomlParser To parse .toml-files. + * @Griefed + */ class NeoForgeTomlScanner(tomlParser: TomlParser): ForgeTomlScanner(tomlParser) { override val modsToml: String get() = "META-INF/neoforge.mods.toml" diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/serverpack/ServerPackGeneration.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/serverpack/ServerPackGeneration.kt index 407b8bf1e..94c57388b 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/serverpack/ServerPackGeneration.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/serverpack/ServerPackGeneration.kt @@ -23,10 +23,37 @@ import de.griefed.serverpackcreator.api.config.PackConfig import java.io.File import java.util.* +/** + * Returned by [de.griefed.serverpackcreator.api.serverpack.ServerPackHandler.run]. Contains information about the + * generated server pack, or the server pack which was attempted to be generated. + * + * @author Griefed + */ class ServerPackGeneration( + /** + * Whether the generation was successful. + */ val success: Boolean, + + /** + * The generated server pack as a file. This usually points towards a directory on the file-system. + */ val serverPack: File, + + /** + * The server pack ZIP-archive, if one was generated. [Optional] for ease of use, as not every server pack generation + * also creates a ZIP-archive. + */ val serverPackZip: Optional, + + /** + * The configuration used in the generation of this server pack. + */ val packConfig: PackConfig, + + /** + * A list of all files in the server pack. These are absolute files, mind you. If you need relative-files, iterate + * through this list and remove the path to the server pack from each entry to receive a list of relative paths. + */ val files: List ) \ No newline at end of file diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/serverpack/ServerPackHandler.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/serverpack/ServerPackHandler.kt index c8b62b71e..d90f35216 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/serverpack/ServerPackHandler.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/serverpack/ServerPackHandler.kt @@ -350,8 +350,7 @@ class ServerPackHandler( relativeFiles, packConfig.minecraftVersion, packConfig.modloader, - packConfig.modloaderVersion, - apiProperties.apiVersion + packConfig.modloaderVersion ) serverPackManifest.writeToFile(serverPack, utilities.jsonUtilities.objectMapper) diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/serverpack/ServerPackManifest.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/serverpack/ServerPackManifest.kt index 7acc39cb3..85bbabb40 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/serverpack/ServerPackManifest.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/serverpack/ServerPackManifest.kt @@ -20,27 +20,37 @@ package de.griefed.serverpackcreator.api.serverpack import com.fasterxml.jackson.databind.ObjectMapper +import de.griefed.serverpackcreator.api.ApiWrapper import java.io.File +/** + * The server pack manifest shipped with every modpack. It includes information about the + * * Minecraft version + * * Modloader + * * Modloader version + * * ServerPackCreator version used in the generation of this server pack + * * A list of relative files included in a server pack + * + * @author Griefed + */ +@Suppress("unused") class ServerPackManifest { var files: List = ArrayList(10000) var minecraftVersion: String = "" var modloader: String = "" var modloaderVersion: String = "" - var serverPackCreatorVersion: String = "" + val serverPackCreatorVersion: String = ApiWrapper.api().apiProperties.apiVersion constructor( files: List, minecraftVersion: String, modloader: String, modloaderVersion: String, - serverPackCreatorVersion: String ) { this.files = files this.minecraftVersion = minecraftVersion this.modloader = modloader this.modloaderVersion = modloaderVersion - this.serverPackCreatorVersion = serverPackCreatorVersion } constructor() diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/utilities/SPCListeners.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/utilities/SPCListeners.kt index ee2e0cc2b..5f775ef9f 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/utilities/SPCListeners.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/utilities/SPCListeners.kt @@ -27,18 +27,67 @@ interface SPCGenericListener { fun run() } +/** + * Config check-listener executed during the checking of a given server pack configuration. + * + * @author Griefed + */ interface SPCConfigCheckListener { - fun run(packConfig: PackConfig,configCheck: ConfigCheck = ConfigCheck()) + + /** + * Run the given listener with a config and a config check object. + * + * @param packConfig A pack config from which a server pack can be generated. + * @param configCheck Config check object holding check results. + */ + fun run(packConfig: PackConfig, configCheck: ConfigCheck = ConfigCheck()) } +/** + * Pre-Server Pack listener executed before a server pack is generated. + * + * @author Griefed + */ interface SPCPreServerPackGenerationListener { + + /** + * Run the given listener with a config and path to the server pack. + * + * @param packConfig A pack config from which a server pack can be generated. + * @param serverPackPath The path to the server pack in question. + */ fun run(packConfig: PackConfig, serverPackPath: Path) } +/** + * Pre ZIP-archive listener executed before a server pack ZIP-archive is created. + * Whether a ZIP-archive for a server pack is actually generated has no effect on whether this listener gets fired. + * + * @author Griefed + */ interface SPCPreServerPackZipListener { + + /** + * Run the given listener with a config and path to the server pack. + * + * @param packConfig A pack config from which a server pack can be generated. + * @param serverPackPath The path to the server pack in question. + */ fun run(packConfig: PackConfig, serverPackPath: Path) } +/** + * Post Generation listener executed after the server pack was generated. + * + * @author Griefed + */ interface SPCPostGenListener { + + /** + * Run the given listener with a config and path to the server pack. + * + * @param packConfig A pack config from which a server pack can be generated. + * @param serverPackPath The path to the server pack in question. + */ fun run(packConfig: PackConfig, serverPackPath: Path) } \ No newline at end of file diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/utilities/common/SemanticVersionComparator.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/utilities/common/SemanticVersionComparator.kt index 36b85e248..287aaf134 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/utilities/common/SemanticVersionComparator.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/utilities/common/SemanticVersionComparator.kt @@ -1,3 +1,22 @@ +/* Copyright (C) 2024 Griefed + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * The full license can be found at https:github.com/Griefed/ServerPackCreator/blob/main/LICENSE + */ package de.griefed.serverpackcreator.api.utilities.common /** diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/utilities/common/UtilityEnums.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/utilities/common/UtilityEnums.kt index c1016b229..714f4d590 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/utilities/common/UtilityEnums.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/utilities/common/UtilityEnums.kt @@ -1,3 +1,22 @@ +/* Copyright (C) 2024 Griefed + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * The full license can be found at https:github.com/Griefed/ServerPackCreator/blob/main/LICENSE + */ package de.griefed.serverpackcreator.api.utilities.common enum class Comparison { diff --git a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/versionmeta/neoforge/NeoForgeInstance.kt b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/versionmeta/neoforge/NeoForgeInstance.kt index f47a039b2..3f30a09f3 100644 --- a/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/versionmeta/neoforge/NeoForgeInstance.kt +++ b/serverpackcreator-api/src/main/kotlin/de/griefed/serverpackcreator/api/versionmeta/neoforge/NeoForgeInstance.kt @@ -1,3 +1,22 @@ +/* Copyright (C) 2024 Griefed + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * The full license can be found at https:github.com/Griefed/ServerPackCreator/blob/main/LICENSE + */ package de.griefed.serverpackcreator.api.versionmeta.neoforge import de.griefed.serverpackcreator.api.versionmeta.minecraft.MinecraftClient diff --git a/serverpackcreator-api/src/test/kotlin/de/griefed/serverpackcreator/api/ConfigurationHandlerTest.kt b/serverpackcreator-api/src/test/kotlin/de/griefed/serverpackcreator/api/ConfigurationHandlerTest.kt index 73b42129d..cb10c6391 100644 --- a/serverpackcreator-api/src/test/kotlin/de/griefed/serverpackcreator/api/ConfigurationHandlerTest.kt +++ b/serverpackcreator-api/src/test/kotlin/de/griefed/serverpackcreator/api/ConfigurationHandlerTest.kt @@ -670,7 +670,7 @@ internal class ConfigurationHandlerTest { includeZipCreation = true, scriptSettings = HashMap(10), pluginsConfigs = HashMap>(10) - ).save(File("tests/serverpackcreatorfabric.conf"), apiProperties) + ).save(File("tests/serverpackcreatorfabric.conf")) ) Assertions.assertTrue(File("tests/serverpackcreatorfabric.conf").exists()) } @@ -741,7 +741,7 @@ internal class ConfigurationHandlerTest { includeZipCreation = true, scriptSettings = HashMap(10), pluginsConfigs = HashMap>(10) - ).save(File("tests/serverpackcreatorforge.conf"), apiProperties) + ).save(File("tests/serverpackcreatorforge.conf")) ) Assertions.assertTrue(File("tests/serverpackcreatorforge.conf").exists()) } @@ -792,7 +792,7 @@ internal class ConfigurationHandlerTest { packConfig.modloader = "Forge" packConfig.modloaderVersion = "36.1.2" packConfig.javaArgs = "tf3g4jz89agz843fag8z49a3zg8ap3jg8zap9vagv3z8j" - Assertions.assertNotNull(packConfig.save(File("tests/somefile.conf"), apiProperties)) + Assertions.assertNotNull(packConfig.save(File("tests/somefile.conf"))) Assertions.assertTrue(File("tests/somefile.conf").exists()) } diff --git a/serverpackcreator-api/src/test/kotlin/de/griefed/serverpackcreator/api/PackConfigTest.kt b/serverpackcreator-api/src/test/kotlin/de/griefed/serverpackcreator/api/PackConfigTest.kt index 5d3cb2429..7c5fa4f98 100644 --- a/serverpackcreator-api/src/test/kotlin/de/griefed/serverpackcreator/api/PackConfigTest.kt +++ b/serverpackcreator-api/src/test/kotlin/de/griefed/serverpackcreator/api/PackConfigTest.kt @@ -40,7 +40,6 @@ class PackConfigTest internal constructor() { @Throws(FileNotFoundException::class, ParserConfigurationException::class) fun scriptSettingsTest() { val packConfig = PackConfig( - ApiWrapper.api(File("src/test/resources/serverpackcreator.properties")).utilities, File("src/test/resources/testresources/spcconfs/scriptSettings.conf") ) Assertions.assertEquals( @@ -125,7 +124,7 @@ class PackConfigTest internal constructor() { val afterFile = File(apiProperties.homeDirectory,"after.conf") packConfig.save(afterFile, apiProperties) val after = PackConfig( - ApiWrapper.api(File("src/test/resources/serverpackcreator.properties")).utilities, afterFile + afterFile ) Assertions.assertEquals(after.serverIconPath, packConfig.serverIconPath) Assertions.assertEquals(after.serverPackSuffix, packConfig.serverPackSuffix) diff --git a/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/cli/ConfigurationEditor.kt b/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/cli/ConfigurationEditor.kt index 97abed519..e9b033889 100644 --- a/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/cli/ConfigurationEditor.kt +++ b/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/cli/ConfigurationEditor.kt @@ -107,7 +107,7 @@ class ConfigurationEditor( try { cliLog(Translations.cli_config_load_edit_input.toString()) fileName = getNextLine(scanner) - packConfig = PackConfig(utilities, File(fileName)) + packConfig = PackConfig(File(fileName)) configLoaded = true } catch (e: FileNotFoundException) { cliLog(Translations.cli_config_load_edit_error(e.message.toString())) @@ -781,12 +781,12 @@ class ConfigurationEditor( if (BooleanUtilities.readBoolean()) { cliLog(Translations.cli_config_save_name.toString()) val customFileName = File(StringUtilities.pathSecureText(getNextLine(scanner))).absoluteFile - packConfig.save(customFileName, apiProperties) + packConfig.save(customFileName) cliLog(Translations.cli_config_save_saved(customFileName.absolutePath)) cliLog(Translations.cli_config_save_info.toString()) cliLog(Translations.cli_config_save_load(customFileName)) } else { - packConfig.save(apiProperties.defaultConfig, apiProperties) + packConfig.save(apiProperties.defaultConfig) cliLog(Translations.cli_config_save_saved_default.toString()) } } diff --git a/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/ConfigEditor.kt b/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/ConfigEditor.kt index c599af9f2..888663f99 100644 --- a/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/ConfigEditor.kt +++ b/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/ConfigEditor.kt @@ -502,7 +502,7 @@ class ConfigEditor( } else { File(apiWrapper.apiProperties.configsDirectory, modpackName) } - lastConfig = getCurrentConfiguration().save(config, apiWrapper.apiProperties) + lastConfig = getCurrentConfiguration().save(config) configFile = config title.hideWarningIcon() saveSuggestions() diff --git a/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/TabbedConfigsTab.kt b/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/TabbedConfigsTab.kt index 87848f95d..75df1e912 100644 --- a/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/TabbedConfigsTab.kt +++ b/serverpackcreator-app/src/main/kotlin/de/griefed/serverpackcreator/app/gui/window/configs/TabbedConfigsTab.kt @@ -168,10 +168,10 @@ class TabbedConfigsTab( configChooser.dialogType = JFileChooser.SAVE_DIALOG if (configChooser.showSaveDialog(mainFrame.frame) == JFileChooser.APPROVE_OPTION) { if (configChooser.selectedFile.path.endsWith(".conf")) { - editor.getCurrentConfiguration().save(configChooser.selectedFile.absoluteFile, apiWrapper.apiProperties) + editor.getCurrentConfiguration().save(configChooser.selectedFile.absoluteFile) log.debug("Saved configuration to: ${configChooser.selectedFile.absoluteFile}") } else { - editor.getCurrentConfiguration().save(File("${configChooser.selectedFile.absoluteFile}.conf"), apiWrapper.apiProperties) + editor.getCurrentConfiguration().save(File("${configChooser.selectedFile.absoluteFile}.conf")) log.debug("Saved configuration to: ${configChooser.selectedFile.absoluteFile}.conf") } } @@ -193,7 +193,7 @@ class TabbedConfigsTab( @Suppress("MemberVisibilityCanBePrivate") fun loadConfig(configFile: File, tab: ConfigEditor = addTab()) { if (configFile.isFile) { - tab.loadConfiguration(PackConfig(apiWrapper.utilities, configFile), configFile) + tab.loadConfiguration(PackConfig(configFile), configFile) } else { GlobalScope.launch(Dispatchers.Swing, CoroutineStart.UNDISPATCHED) { JOptionPane.showMessageDialog(