ConfigurationHandler

Check any given PackConfig for errors and, if so desired, add them to a passed list of errors, so you may display them in a GUI, CLI or website. The most important method is checkConfiguration and all of its variants which will check your passed configuration model for errors, indicating whether it is safe to use for further operations. Running your model through the checks also ensures that the default script settings are present and set according to your pack's environment.

Author

Griefed

actual class ConfigurationHandler(versionMeta: VersionMeta, apiProperties: ApiProperties, utilities: Utilities, apiPlugins: ApiPlugins) : Configuration<File, Path>

Check any given PackConfig for errors and, if so desired, add them to a passed list of errors, so you may display them in a GUI, CLI or website. The most important method is checkConfiguration and all of its variants which will check your passed configuration model for errors, indicating whether it is safe to use for further operations. Running your model through the checks also ensures that the default script settings are present and set according to your pack's environment.

Author

Griefed

Parameters

apiProperties

Base settings of SPC used just about everywhere.

versionMeta

Meta used for Minecraft and modloader version checks and verification.

utilities

Common utilities used all across SPC.

apiPlugins

Addons and extensions added by external addons which can add additional checks to a given configuration check.

Constructors

Link copied to clipboard
constructor(versionMeta: VersionMeta, apiProperties: ApiProperties, utilities: Utilities, apiPlugins: ApiPlugins)

Properties

Link copied to clipboard
protected val fabric: Regex
Link copied to clipboard
protected val forge: Regex
Link copied to clipboard
protected val legacyFabric: Regex
Link copied to clipboard
protected val log: KLogger
Link copied to clipboard
protected val neoForge: Regex
Link copied to clipboard
protected val previous: Regex
Link copied to clipboard
protected val quilt: Regex
Link copied to clipboard
protected val whitespace: Regex
Link copied to clipboard
protected val zipCheck: Regex

Functions

Link copied to clipboard
expect fun checkConfiguration(packConfig: PackConfig = PackConfig(), configCheck: ConfigCheck = ConfigCheck(), quietCheck: Boolean = false): ConfigCheck
expect fun checkConfiguration(configFile: File, packConfig: PackConfig = PackConfig(), configCheck: ConfigCheck = ConfigCheck(), quietCheck: Boolean = false): ConfigCheck
actual open override fun checkConfiguration(packConfig: PackConfig, configCheck: ConfigCheck, quietCheck: Boolean): ConfigCheck

Check the passed packConfig. If any check returns true then the server pack will not be created. In order to find out which check failed, the user has to check their serverpackcreator.log in the logs-directory.

Link copied to clipboard
expect fun checkIconAndProperties(iconOrPropertiesPath: String = ""): Boolean
actual open override fun checkIconAndProperties(iconOrPropertiesPath: String): Boolean

Checks the passed String whether it is an existing file. If the passed String is empty, then ServerPackCreator will treat it as the user being fine with the default files and return the corresponding boolean.

Link copied to clipboard
expect fun checkInclusions(inclusions: MutableList<InclusionSpecification>, modpackDir: String, configCheck: ConfigCheck = ConfigCheck(), printLog: Boolean = true): ConfigCheck
actual open override fun checkInclusions(inclusions: MutableList<InclusionSpecification>, modpackDir: String, configCheck: ConfigCheck, printLog: Boolean): ConfigCheck

Checks whether the passed list of directories which are supposed to be in the modpack directory is empty, or whether all directories in the list exist in the modpack directory. If the user specified a source/file;destination/file-combination, it is checked whether the specified source-file exists on the host.

Link copied to clipboard
expect fun checkManifests(destination: String, packConfig: PackConfig, configCheck: ConfigCheck = ConfigCheck()): String?
actual open override fun checkManifests(destination: String, packConfig: PackConfig, configCheck: ConfigCheck): String?

Check whether various manifests from various launchers exist and use them to update our ConfigurationModel and pack name.

Link copied to clipboard
expect fun checkModloader(modloader: String, configCheck: ConfigCheck = ConfigCheck()): ConfigCheck
actual open override fun checkModloader(modloader: String, configCheck: ConfigCheck): ConfigCheck

Checks whether either Forge or Fabric were specified as the modloader.

Link copied to clipboard
expect fun checkModloaderVersion(modloader: String, modloaderVersion: String, minecraftVersion: String, configCheck: ConfigCheck = ConfigCheck()): ConfigCheck
actual open override fun checkModloaderVersion(modloader: String, modloaderVersion: String, minecraftVersion: String, configCheck: ConfigCheck): ConfigCheck

Check the given Minecraft and modloader versions for the specified modloader.

Link copied to clipboard
expect fun checkModpackDir(modpackDir: String, configCheck: ConfigCheck = ConfigCheck(), printLog: Boolean = true): ConfigCheck
actual open override fun checkModpackDir(modpackDir: String, configCheck: ConfigCheck, printLog: Boolean): ConfigCheck

Check the passed directory for existence and whether it is a directory, rather than a file.

Link copied to clipboard
expect fun checkServerPacksForIncrement(source: String, destination: String): String
actual open override fun checkServerPacksForIncrement(source: String, destination: String): String

Check whether a server pack for the given destination already exists and get an incrementor based on whether one exists, how many, or none exist. Think if this as the incrementation Windows does when a file of the same name is copied. foo.bar becomes foo (1).bar etc.

Link copied to clipboard
expect fun checkZipArchive(pathToZip: String, configCheck: ConfigCheck = ConfigCheck()): ConfigCheck
actual open override fun checkZipArchive(pathToZip: String, configCheck: ConfigCheck): ConfigCheck

Check a given ZIP-archives contents. If the ZIP-archive only contains one directory, or if it contains neither the mods nor the config directories, consider it invalid.

Link copied to clipboard
actual open override fun ensureScriptSettingsDefaults(packConfig: PackConfig)

Update the script settings and ensure the default keys, with values gathered from the passed PackConfig, are present:

Link copied to clipboard
Link copied to clipboard
expect fun getFilesInModpackZip(zipFile: File): List<String>
Link copied to clipboard
fun getModLoaderCase(modloader: String): String

Ensures the modloader is normalized to first letter upper case and rest lower case. Basically allows the user to input Forge or Fabric in any combination of upper- and lowercase and ServerPackCreator will still be able to work with the users input.

Link copied to clipboard
expect fun isDir(packConfig: PackConfig, configCheck: ConfigCheck = ConfigCheck()): ConfigCheck
actual open override fun isDir(packConfig: PackConfig, configCheck: ConfigCheck): ConfigCheck

If the in the configuration specified modpack dir is an existing directory, checks are made for valid configuration of: directories to copy to server pack, if includeServerInstallation is true path to Java executable/binary, Minecraft version, modloader and modloader version.

Link copied to clipboard
expect fun isZip(packConfig: PackConfig, configCheck: ConfigCheck = ConfigCheck()): ConfigCheck
actual open override fun isZip(packConfig: PackConfig, configCheck: ConfigCheck): ConfigCheck

Checks the specified ZIP-archive for validity. In order for a modpack ZIP-archive to be considered valid, it needs to contain the mods and config folders at minimum. If any of manifest.json, minecraftinstance.json or config.json are available, gather as much information from them as possible.

Link copied to clipboard
expect fun printConfigurationModel(modpackDirectory: String, clientsideMods: List<String>, inclusions: List<InclusionSpecification>, minecraftVer: String, modloader: String, modloaderVersion: String, includeIcon: Boolean, includeProperties: Boolean, includeZip: Boolean, javaArgs: String, serverPackSuffix: String, serverIconPath: String, serverPropertiesPath: String, scriptSettings: <Error class: unknown class><String, String>)
fun printConfigurationModel(packConfig: Pack<*, *, *>)

Convenience method which passes the important fields from an instance of PackConfig to .printConfigurationModel

Link copied to clipboard
fun printEncounteredErrors(encounteredErrors: List<String>)

Print all encountered errors to logs.

Link copied to clipboard
expect fun sanitizeLinks(packConfig: PackConfig)
actual open override fun sanitizeLinks(packConfig: PackConfig)

Sanitize any and all links in a given instance of PackConfig modpack-directory, server-icon path, server-properties path, Java path and copy-directories entries.

Link copied to clipboard
expect fun suggestInclusions(modpackDir: String): <Error class: unknown class><InclusionSpecification>
actual open override fun suggestInclusions(modpackDir: String): <Error class: unknown class><InclusionSpecification>

Creates a list of suggested directories to include in server pack which is later on written to a new configuration file. The list of directories to include in the server pack which is generated by this method excludes well know directories which would not be needed by a server pack. If you have suggestions to this list, open a feature request issue on GitHub

Link copied to clipboard
expect fun unzipDestination(destination: String): String
actual open override fun unzipDestination(destination: String): String

Update the destination to which the ZIP-archive will the extracted to, based on whether a directory of the same name already exists.

Link copied to clipboard
expect fun updateConfigModelFromConfigJson(packConfig: PackConfig, config: File)
Link copied to clipboard
expect fun updateConfigModelFromCurseManifest(packConfig: PackConfig, manifest: File)
Link copied to clipboard
expect fun updateConfigModelFromInstance(packConfig: PackConfig, manifest: File)
Link copied to clipboard
expect fun updateConfigModelFromMinecraftInstance(packConfig: PackConfig, minecraftInstance: File)
Link copied to clipboard
expect fun updateConfigModelFromMMCPack(packConfig: PackConfig, mmcPack: File)
Link copied to clipboard
expect fun updateConfigModelFromModrinthManifest(packConfig: PackConfig, manifest: File)
Link copied to clipboard
expect fun updateDestinationFromInstanceCfg(instanceCfg: File): String
Link copied to clipboard
expect fun updatePackName(packConfig: PackConfig, vararg childNodes: String): String?
actual open override fun updatePackName(packConfig: PackConfig, vararg childNodes: String): String?

Acquire the modpacks name from the JSON previously acquired and stored in the ConfigurationModel.