ConfigurationHandler

class ConfigurationHandler(versionMeta: VersionMeta, apiProperties: ApiProperties, utilities: Utilities, apiPlugins: ApiPlugins)

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
val fabric: <Error class: unknown class>
Link copied to clipboard
val forge: <Error class: unknown class>
Link copied to clipboard
val legacyFabric: <Error class: unknown class>
Link copied to clipboard
val log: <Error class: unknown class>
Link copied to clipboard
val neoForge: <Error class: unknown class>
Link copied to clipboard
val previous: <Error class: unknown class>
Link copied to clipboard
val quilt: <Error class: unknown class>
Link copied to clipboard
val whitespace: <Error class: unknown class>
Link copied to clipboard
val zipCheck: <Error class: unknown class>

Functions

Link copied to clipboard
fun addEventListener(configEventListener: SPCConfigCheckListener)
fun addEventListener(genericEventListener: SPCGenericListener)
Link copied to clipboard
fun checkConfiguration(packConfig: PackConfig, configCheck: ConfigCheck = ConfigCheck(), quietCheck: Boolean = false): 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.

fun checkConfiguration(configFile: File, packConfig: PackConfig = PackConfig(), configCheck: ConfigCheck = ConfigCheck(), quietCheck: Boolean = false): ConfigCheck

Check the passed configuration-file. 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

Check for minecraftinstance.json and profile.json and if either is present, try to obtain the project- and fileIDs as well as the modpack distribution-platform (Modrinth or CurseForge).

Link copied to clipboard
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
fun checkInclusions(inclusions: MutableList<InclusionSpecification>, modpackDir: String, configCheck: ConfigCheck = ConfigCheck(), printLog: Boolean = true): 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
fun checkManifests(destination: String, packConfig: PackConfig, configCheck: 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
fun checkModloader(modloader: String, configCheck: ConfigCheck = ConfigCheck()): ConfigCheck

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

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

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

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

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

Link copied to clipboard
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
fun checkZipArchive(pathToZip: String, configCheck: 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

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

Link copied to clipboard
fun generateConfigFromModpack(modpackDirectory: File): PackConfig

Generate a PackConfig from a modpack-directory, resulting in a basic server pack configuration with default values, for an easy-to-use starting point of a server pack config.

Link copied to clipboard

Acquire a list of all files and directories in a ZIP-file.

Link copied to clipboard

Acquire a list of all directories in a ZIP-file. The resulting list excludes files.

Link copied to clipboard

Acquire a list of directories in the base-directory of a ZIP-file.

Link copied to clipboard

Acquire a list of all files in a ZIP-file. The resulting list excludes directories.

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
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
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

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

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: HashMap<String, String>)

Prints all passed fields to the console and serverpackcreator.log. Used to show the user the configuration before ServerPackCreator starts the generation of the server pack or, if checks failed, to show the user their last configuration, so they can more easily identify problems with said configuration.

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

Print all encountered errors to logs.

Link copied to clipboard
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

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
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

instance.json

Link copied to clipboard

config.json

Link copied to clipboard

manifest.json

Link copied to clipboard

parentDirectory/instance.json

Link copied to clipboard
fun updateConfigModelFromMinecraftInstance(packConfig: PackConfig, minecraftInstance: File)

minecraftinstance.json

Link copied to clipboard
fun updateConfigModelFromMMCPack(packConfig: PackConfig, mmcPack: File)

mmc-pack.json

Link copied to clipboard

modrinth.index.json

Link copied to clipboard

instance.cfg

Link copied to clipboard
fun updatePackName(packConfig: PackConfig, vararg childNodes: String): String?

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