@Component
public final class ConfigurationHandler
extends java.lang.Object
ConfigurationModel 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(ConfigurationModel, boolean) 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.| Constructor and Description |
|---|
ConfigurationHandler(I18n injectedI18n,
VersionMeta injectedVersionMeta,
ApplicationProperties injectedApplicationProperties,
Utilities injectedUtilities,
ApplicationAddons injectedApplicationAddons)
Construct a new ConfigurationHandler giving you access to various config check methods.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkConfiguration(@NotNull ConfigurationModel configurationModel,
boolean quietCheck)
Check the passed
ConfigurationModel. |
boolean |
checkConfiguration(@NotNull ConfigurationModel configurationModel,
@NotNull java.util.List<java.lang.String> encounteredErrors,
boolean quietCheck)
Check the passed
ConfigurationModel. |
boolean |
checkConfiguration(@NotNull java.io.File configFile,
boolean quietCheck)
Check the passed configuration-file.
|
boolean |
checkConfiguration(@NotNull java.io.File configFile,
@NotNull ConfigurationModel configurationModel,
boolean quietCheck)
Check the passed configuration-file.
|
boolean |
checkConfiguration(@NotNull java.io.File configFile,
@NotNull ConfigurationModel configurationModel,
@NotNull java.util.List<java.lang.String> encounteredErrors,
boolean quietCheck)
Check the passed configuration-file.
|
boolean |
checkConfiguration(@NotNull java.io.File configFile,
@NotNull java.util.List<java.lang.String> encounteredErrors,
boolean quietCheck)
Check the passed configuration-file.
|
boolean |
checkCopyDirs(@NotNull java.util.List<java.lang.String> directoriesToCopy,
@NotNull java.lang.String modpackDir)
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.
|
boolean |
checkCopyDirs(@NotNull java.util.List<java.lang.String> directoriesToCopy,
@NotNull java.lang.String modpackDir,
@NotNull java.util.List<java.lang.String> encounteredErrors)
Checks whether the passed list of directories which are supposed to be in the modpack directory
is empty and prints a message to the console and serverpackcreator.log if it is.
Checks whether all directories in the list exist in the modpack directory and prints a message to the console and serverpackcreator.log if any one of the directories could not be found. |
boolean |
checkIconAndProperties(@NotNull java.lang.String iconOrPropertiesPath)
Checks the passed String whether it is an existing file.
|
@Nullable java.lang.String |
checkManifests(@NotNull java.lang.String destination,
@NotNull ConfigurationModel configurationModel,
@NotNull java.util.List<java.lang.String> encounteredErrors)
Check whether various manifests from various launchers exist and use them to update our
ConfigurationModel and pack name.
|
boolean |
checkModloader(@NotNull java.lang.String modloader)
Checks whether either Forge or Fabric were specified as the modloader.
|
boolean |
checkModloaderVersion(@NotNull java.lang.String modloader,
@NotNull java.lang.String modloaderVersion,
@NotNull java.lang.String minecraftVersion)
Check the given Minecraft and modloader versions for the specified modloader.
|
boolean |
checkModloaderVersion(@NotNull java.lang.String modloader,
@NotNull java.lang.String modloaderVersion,
@NotNull java.lang.String minecraftVersion,
@NotNull java.util.List<java.lang.String> encounteredErrors)
Check the given Minecraft and modloader versions for the specified modloader and update the
passed error-list should any error be encountered.
|
boolean |
checkModpackDir(@NotNull java.lang.String modpackDir)
Check the passed directory for existence and whether it is a directory, rather than a file.
|
boolean |
checkModpackDir(@NotNull java.lang.String modpackDir,
@NotNull java.util.List<java.lang.String> encounteredErrors)
Checks whether the passed String is empty and if it is empty, prints the corresponding message
to the console and serverpackcreator.log so the user knows what went wrong.
Checks whether the passed String is a directory and if it is not, prints the corresponding message to the console and serverpackcreator.log so the user knows what went wrong. |
boolean |
checkRegex(@NotNull java.lang.String modpackDir,
@NotNull java.lang.String entry,
boolean exclusion)
Check the given entry for valid regex.
|
boolean |
checkRegex(@NotNull java.lang.String modpackDir,
@NotNull java.lang.String entry,
boolean exclusion,
@NotNull java.util.List<java.lang.String> encounteredErrors)
Check the given entry for valid regex.
|
boolean |
checkZipArchive(@NotNull java.nio.file.Path pathToZip,
@NotNull java.util.List<java.lang.String> encounteredErrors)
Check a given ZIP-archives contents.
|
void |
ensureScriptSettingsDefaults(@NotNull ConfigurationModel configurationModel)
Update the script settings and ensure the default keys, with values gathered from the passed
ConfigurationModel, are present:
SPC_SERVERPACKCREATOR_VERSION_SPC : ServerPackCreator version with which the scripts were created
SPC_MINECRAFT_VERSION_SPC : Minecraft version of the modpack
SPC_MINECRAFT_SERVER_URL_SPC : Download-URL to the Minecraft server
SPC_MODLOADER_SPC : The modloader of the modpack
SPC_MODLOADER_VERSION_SPC : The modloader version of the modpack
SPC_JAVA_ARGS_SPC : The JVM args to be used to run the server
SPC_JAVA_SPC : Path to the java installation to be used to run the server
SPC_FABRIC_INSTALLER_VERSION_SPC : Most recent version of the Fabric installer at the time of creating the scripts
SPC_QUILT_INSTALLER_VERSION_SPC : Most recent version of the Quilt installer at the time of creating the scripts
|
@NotNull java.util.List<java.lang.String> |
getAllFilesAndDirectoriesInModpackZip(@NotNull net.lingala.zip4j.ZipFile zipFile)
Acquire a list of all files and directories in a ZIP-file.
|
@NotNull java.util.List<java.lang.String> |
getDirectoriesInModpackZip(@NotNull net.lingala.zip4j.ZipFile zipFile)
Acquire a list of all directories in a ZIP-file.
|
@NotNull java.util.List<java.lang.String> |
getDirectoriesInModpackZipBaseDirectory(@NotNull net.lingala.zip4j.ZipFile zipFile)
Acquire a list of directories in the base-directory of a ZIP-file.
|
@NotNull java.util.List<java.lang.String> |
getFilesInModpackZip(@NotNull net.lingala.zip4j.ZipFile zipFile)
Acquire a list of all files in a ZIP-file.
|
@NotNull java.lang.String |
getModLoaderCase(@NotNull java.lang.String modloader)
Ensures the modloader is normalized to first letter upper case and rest lower case.
|
boolean |
isDir(@NotNull ConfigurationModel configurationModel,
@NotNull java.util.List<java.lang.String> encounteredErrors)
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. |
boolean |
isZip(@NotNull ConfigurationModel configurationModel,
@NotNull java.util.List<java.lang.String> encounteredErrors)
Checks the specified ZIP-archive for validity.
|
void |
printConfigurationModel(@NotNull ConfigurationModel configurationModel)
Convenience method which passes the important fields from an instance of
ConfigurationModel to
printConfigurationModel(String, List, List, boolean, String, String, String, boolean,
boolean, boolean, String, String, String, String, HashMap) |
void |
printConfigurationModel(@NotNull java.lang.String modpackDirectory,
@NotNull java.util.List<java.lang.String> clientsideMods,
@NotNull java.util.List<java.lang.String> copyDirectories,
boolean installServer,
@NotNull java.lang.String minecraftVer,
@NotNull java.lang.String modloader,
@NotNull java.lang.String modloaderVersion,
boolean includeIcon,
boolean includeProperties,
boolean includeZip,
@NotNull java.lang.String javaArgs,
@NotNull java.lang.String serverPackSuffix,
@NotNull java.lang.String serverIconPath,
@NotNull java.lang.String serverPropertiesPath,
@NotNull java.util.HashMap<java.lang.String,java.lang.String> scriptSettings)
Prints all passed fields to the console and serverpackcreator.log.
|
void |
sanitizeLinks(@NotNull ConfigurationModel configurationModel)
Sanitize any and all links in a given instance of
ConfigurationModel modpack-directory,
server-icon path, server-properties path, Java path and copy-directories entries. |
@NotNull java.util.List<java.lang.String> |
suggestCopyDirs(@NotNull java.lang.String modpackDir)
Creates a list of suggested directories to include in server pack which is later on written to
a new configuration file.
|
void |
updateConfigModelFromATLauncherInstance(@NotNull ConfigurationModel configurationModel,
@NotNull java.io.File manifest)
instance.json |
void |
updateConfigModelFromConfigJson(@NotNull ConfigurationModel configurationModel,
@NotNull java.io.File config)
config.json |
void |
updateConfigModelFromCurseManifest(@NotNull ConfigurationModel configurationModel,
@NotNull java.io.File manifest)
manifest.json |
void |
updateConfigModelFromMinecraftInstance(@NotNull ConfigurationModel configurationModel,
@NotNull java.io.File minecraftInstance)
minecraftinstance.json |
void |
updateConfigModelFromMMCPack(@NotNull ConfigurationModel configurationModel,
@NotNull java.io.File mmcPack)
mmc-pack.json |
void |
updateConfigModelFromModrinthManifest(@NotNull ConfigurationModel configurationModel,
@NotNull java.io.File manifest)
modrinth.index.json |
@NotNull java.lang.String |
updateDestinationFromInstanceCfg(@NotNull java.io.File instanceCfg)
instance.cfg |
@Autowired public ConfigurationHandler(I18n injectedI18n, VersionMeta injectedVersionMeta, ApplicationProperties injectedApplicationProperties, Utilities injectedUtilities, ApplicationAddons injectedApplicationAddons)
injectedI18n - Used to add localized error messages during configuration
checks.injectedApplicationProperties - Base settings of SPC used just about everywhere.injectedVersionMeta - Meta used for Minecraft and modloader version checks and
verification.injectedUtilities - Common utilities used all across SPC.injectedApplicationAddons - Addons and extensions added by external addons which can
add additional checks to a given configuration check.public boolean checkConfiguration(@NotNull
@NotNull java.io.File configFile,
@NotNull
@NotNull java.util.List<java.lang.String> encounteredErrors,
boolean quietCheck)
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.configFile - The configuration file to check. Must either be an existing file to
load a configuration from or null if you want to use the passed
configuration model.encounteredErrors - A list of errors encountered during configuration checks which gets
printed to the console and log after all checks have run. Gives the
user more detail on what went wrong at which part of their
configuration. Can be used to display the errors, if any were
encountered, in a UI or be printed into the console or whatever have
you.quietCheck - Whether the configuration should be printed to the console and logs.
Pass false to quietly check the configuration.false if the configuration has passed all tests.public boolean checkConfiguration(@NotNull
@NotNull java.io.File configFile,
@NotNull
@NotNull ConfigurationModel configurationModel,
@NotNull
@NotNull java.util.List<java.lang.String> encounteredErrors,
boolean quietCheck)
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.configFile - The configuration file to check. Must either be an existing file to
load a configuration from or null if you want to use the passed
configuration model.configurationModel - Instance of a configuration of a modpack. Can be used to further
display or use any information within, as it may be changed or
otherwise altered by this method.encounteredErrors - A list of errors encountered during configuration checks which gets
printed to the console and log after all checks have run. Gives the
user more detail on what went wrong at which part of their
configuration. Can be used to display the errors, if any were
encountered, in a UI or be printed into the console or whatever have
you.quietCheck - Whether the configuration should be printed to the console and logs.
Pass false to quietly check the configuration.false if the configuration has passed all tests.public boolean checkConfiguration(@NotNull
@NotNull ConfigurationModel configurationModel,
@NotNull
@NotNull java.util.List<java.lang.String> encounteredErrors,
boolean quietCheck)
ConfigurationModel. 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.encounteredErrors can be used to display the errors, if any were encountered, in a UI
or be printed into the console or whatever have you.ConfigurationModel
can be used to further display or use any information within, as it may be changed or otherwise
altered by this method.configurationModel - Instance of a configuration of a modpack. Can be used to further
display or use any information within, as it may be changed or
otherwise altered by this method.encounteredErrors - A list of errors encountered during configuration checks which gets
printed to the console and log after all checks have run. Gives the
user more detail on what went wrong at which part of their
configuration. Can be used to display the errors, if any were
encountered, in a UI or be printed into the console or whatever have
you.quietCheck - Whether the configuration should be printed to the console and logs.
Pass false to quietly check the configuration.false if all checks are passed.public void sanitizeLinks(@NotNull
@NotNull ConfigurationModel configurationModel)
ConfigurationModel modpack-directory,
server-icon path, server-properties path, Java path and copy-directories entries.configurationModel - Instance of ConfigurationModel in which to sanitize links to
their respective destinations.public boolean checkIconAndProperties(@NotNull
@NotNull java.lang.String iconOrPropertiesPath)
iconOrPropertiesPath - The path to the custom server-icon.png or server.properties file to
check.public boolean isDir(@NotNull
@NotNull ConfigurationModel configurationModel,
@NotNull
@NotNull java.util.List<java.lang.String> encounteredErrors)
true path to Java executable/binary, Minecraft version, modloader and modloader
version.configurationModel - An instance of ConfigurationModel which contains the
configuration of the modpack.encounteredErrors - A list to which all encountered errors are saved to.true if an error is found during configuration check.public boolean isZip(@NotNull
@NotNull ConfigurationModel configurationModel,
@NotNull
@NotNull java.util.List<java.lang.String> encounteredErrors)
throws java.io.IOException
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.configurationModel - Instance of ConfigurationModel with a server pack
configuration.encounteredErrors - A list of errors encountered during configuration checks.false when no errors were encountered.java.io.IOException - if an error occurred trying to move the server pack directory.public boolean checkModloader(@NotNull
@NotNull java.lang.String modloader)
modloader - Check as case-insensitive for Forge or Fabric.public boolean checkModloaderVersion(@NotNull
@NotNull java.lang.String modloader,
@NotNull
@NotNull java.lang.String modloaderVersion,
@NotNull
@NotNull java.lang.String minecraftVersion,
@NotNull
@NotNull java.util.List<java.lang.String> encounteredErrors)
modloader - String. The passed modloader which determines whether the check for
Forge or Fabric is called.modloaderVersion - String. The version of the modloader which is checked against the
corresponding modloaders manifest.minecraftVersion - String. The version of Minecraft used for checking the Forge version.encounteredErrors - List of encountered errors to add to in case of errors.true if the specified modloader version was found in the corresponding
manifest.public void printConfigurationModel(@NotNull
@NotNull ConfigurationModel configurationModel)
ConfigurationModel to
printConfigurationModel(String, List, List, boolean, String, String, String, boolean,
boolean, boolean, String, String, String, String, HashMap)configurationModel - Instance of ConfigurationModel to print to console and logs.public void ensureScriptSettingsDefaults(@NotNull
@NotNull ConfigurationModel configurationModel)
ConfigurationModel, are present:
SPC_SERVERPACKCREATOR_VERSION_SPC : ServerPackCreator version with which the scripts were created
SPC_MINECRAFT_VERSION_SPC : Minecraft version of the modpack
SPC_MINECRAFT_SERVER_URL_SPC : Download-URL to the Minecraft server
SPC_MODLOADER_SPC : The modloader of the modpack
SPC_MODLOADER_VERSION_SPC : The modloader version of the modpack
SPC_JAVA_ARGS_SPC : The JVM args to be used to run the server
SPC_JAVA_SPC : Path to the java installation to be used to run the server
SPC_FABRIC_INSTALLER_VERSION_SPC : Most recent version of the Fabric installer at the time of creating the scripts
SPC_QUILT_INSTALLER_VERSION_SPC : Most recent version of the Quilt installer at the time of creating the scripts
configurationModel - Model in which to ensure the default key-value pairs are present.public boolean checkCopyDirs(@NotNull
@NotNull java.util.List<java.lang.String> directoriesToCopy,
@NotNull
@NotNull java.lang.String modpackDir,
@NotNull
@NotNull java.util.List<java.lang.String> encounteredErrors)
source/file;destination/file-combination, it is checked whether the
specified source-file exists on the host.directoriesToCopy - The list of directories, or
source/file;destination/file-combinations, to check for
existence. source/file;destination/file-combinations must be
absolute paths to the source-file.modpackDir - The path to the modpack directory in which to check for existence of
the passed list of directories.encounteredErrors - A list to which all encountered errors are saved to.public boolean checkRegex(@NotNull
@NotNull java.lang.String modpackDir,
@NotNull
@NotNull java.lang.String entry,
boolean exclusion)
====. When starting with ==== must specify an existing directory== must be the regex to match files and/or directoriesmodpackDir - The modpacks directory which will be checked when the entry starts with
==entry - The regex, or file/directory and regex, combination.exclusion - Whether the checks are for exclusions (true) or files and/or
directories, or inclusions (false).true when no errors were encountered.public boolean checkRegex(@NotNull
@NotNull java.lang.String modpackDir,
@NotNull
@NotNull java.lang.String entry,
boolean exclusion,
@NotNull
@NotNull java.util.List<java.lang.String> encounteredErrors)
====. When starting with ==== must specify an existing directory== must be the regex to match files and/or directoriesmodpackDir - The modpacks directory which will be checked when the entry starts
with ==entry - The regex, or file/directory and regex, combination.exclusion - Whether the checks are for exclusions (true) or files and/or
directories, or inclusions (false).encounteredErrors - A list to which all encountered errors are saved to.true when no errors were encountered.public boolean checkZipArchive(@NotNull
@NotNull java.nio.file.Path pathToZip,
@NotNull
@NotNull java.util.List<java.lang.String> encounteredErrors)
pathToZip - Path to the ZIP-file to check.encounteredErrors - List of encountered errors for further processing, like printing to
logs or display in GUI or whatever you want, really.false if the ZIP-archive is considered valid.@NotNull
public @NotNull java.util.List<java.lang.String> suggestCopyDirs(@NotNull
@NotNull java.lang.String modpackDir)
modpackDir - The directory for which to gather a list of directories to copy to the server
pack.@Nullable
public @Nullable java.lang.String checkManifests(@NotNull
@NotNull java.lang.String destination,
@NotNull
@NotNull ConfigurationModel configurationModel,
@NotNull
@NotNull java.util.List<java.lang.String> encounteredErrors)
destination - The destination in which the manifests are.configurationModel - The ConfigurationModel to update.encounteredErrors - A list of errors encountered during configuration checks, to be added
to in case an error is encountered during manifest checks.null if the name could not be
acquired.public void printConfigurationModel(@NotNull
@NotNull java.lang.String modpackDirectory,
@NotNull
@NotNull java.util.List<java.lang.String> clientsideMods,
@NotNull
@NotNull java.util.List<java.lang.String> copyDirectories,
boolean installServer,
@NotNull
@NotNull java.lang.String minecraftVer,
@NotNull
@NotNull java.lang.String modloader,
@NotNull
@NotNull java.lang.String modloaderVersion,
boolean includeIcon,
boolean includeProperties,
boolean includeZip,
@NotNull
@NotNull java.lang.String javaArgs,
@NotNull
@NotNull java.lang.String serverPackSuffix,
@NotNull
@NotNull java.lang.String serverIconPath,
@NotNull
@NotNull java.lang.String serverPropertiesPath,
@NotNull
@NotNull java.util.HashMap<java.lang.String,java.lang.String> scriptSettings)
modpackDirectory - The used modpackDir field either from a configuration file or from
configuration setup.clientsideMods - List of clientside-only mods to exclude from the server pack...copyDirectories - List of directories in the modpack which are to be included in the
server pack.installServer - Whether to install the modloader server in the server pack.minecraftVer - The Minecraft version the modpack uses.modloader - The modloader the modpack uses.modloaderVersion - The version of the modloader the modpack uses.includeIcon - Whether to include the server-icon.png in the server pack.includeProperties - Whether to include the server.properties in the server pack.includeZip - Whether to create a zip-archive of the server pack, excluding the
Minecraft server JAR according to Mojang's TOS and EULA.javaArgs - Java arguments to write the start-scripts with.serverPackSuffix - Suffix to append to name of the server pack to be generated.serverIconPath - The path to the custom server-icon.png to be used in the server
pack.serverPropertiesPath - The path to the custom server.properties to be used in the server
pack.scriptSettings - Custom settings for start script creation. KEYs are the
placeholder, VALUEs are the values with which the
placeholders are to be replaced.@NotNull
public @NotNull java.util.List<java.lang.String> getDirectoriesInModpackZipBaseDirectory(@NotNull
@NotNull net.lingala.zip4j.ZipFile zipFile)
throws java.lang.IllegalArgumentException,
java.nio.file.FileSystemAlreadyExistsException,
java.nio.file.ProviderNotFoundException,
java.io.IOException,
java.lang.SecurityException
zipFile - The ZIP-archive to get the list of files from.java.lang.IllegalArgumentException - if the pre-conditions for the uri parameter are not
met, or the env parameter does not contain properties
required by the provider, or a property value is
invalid.java.nio.file.FileSystemAlreadyExistsException - if the file system has already been created.java.nio.file.ProviderNotFoundException - if a provider supporting the URI scheme is not
installed.java.io.IOException - if an I/O error occurs creating the file system.java.lang.SecurityException - if a security manager is installed, and it denies an
unspecified permission required by the file system
provider implementation.public void updateConfigModelFromCurseManifest(@NotNull
@NotNull ConfigurationModel configurationModel,
@NotNull
@NotNull java.io.File manifest)
throws java.io.IOException
manifest.json
Update the given ConfigurationModel with values gathered from the downloaded CurseForge modpack. A manifest.json-file is usually created when a modpack is exported through launchers like Overwolf's CurseForge or GDLauncher.
configurationModel - An instance containing a configuration for a modpack from which to
create a server pack.manifest - File. The CurseForge manifest.json-file of the modpack to read.java.io.IOException - when the manifest.json-file could not be parsed.public void updateConfigModelFromMinecraftInstance(@NotNull
@NotNull ConfigurationModel configurationModel,
@NotNull
@NotNull java.io.File minecraftInstance)
throws java.io.IOException
minecraftinstance.json
Update the given ConfigurationModel with values gathered from the minecraftinstance.json of the modpack. A minecraftinstance.json is usually created by Overwolf's CurseForge launcher.
configurationModel - An instance containing a configuration for a modpack from which to
create a server pack.minecraftInstance - File. The minecraftinstance.json-file of the modpack to read.java.io.IOException - when the minecraftinstance.json-file could not be parsed.public void updateConfigModelFromModrinthManifest(@NotNull
@NotNull ConfigurationModel configurationModel,
@NotNull
@NotNull java.io.File manifest)
throws java.io.IOException
modrinth.index.json
Update the given ConfigurationModel with values gathered from a Modrinth modrinth.index.json-manifest.
configurationModel - The model to update.manifest - The manifest file.java.io.IOException - when the modrinth.index.json-file could not be parsed.public void updateConfigModelFromATLauncherInstance(@NotNull
@NotNull ConfigurationModel configurationModel,
@NotNull
@NotNull java.io.File manifest)
throws java.io.IOException
instance.json
Update the given ConfigurationModel with values gathered from a ATLauncher manifest.
configurationModel - The model to update.manifest - The manifest file.java.io.IOException - when the instance.json-file could not be parsed.public void updateConfigModelFromConfigJson(@NotNull
@NotNull ConfigurationModel configurationModel,
@NotNull
@NotNull java.io.File config)
throws java.io.IOException
config.json
Update the given ConfigurationModel with values gathered from the modpacks config.json. A config.json is usually created by GDLauncher.
configurationModel - An instance containing a configuration for a modpack from which to
create a server pack.config - The config.json-file of the modpack to read.java.io.IOException - when the config.json-file could not be parsed.public void updateConfigModelFromMMCPack(@NotNull
@NotNull ConfigurationModel configurationModel,
@NotNull
@NotNull java.io.File mmcPack)
throws java.io.IOException
mmc-pack.json
Update the given ConfigurationModel with values gathered from the modpacks mmc-pack.json. A mmc-pack.json is usually created by the MultiMC launcher.
configurationModel - An instance containing a configuration for a modpack from which to
create a server pack.mmcPack - The config.json-file of the modpack to read.java.io.IOException - when the mmc-pack.json-file could not be parsed.@NotNull
public @NotNull java.lang.String updateDestinationFromInstanceCfg(@NotNull
@NotNull java.io.File instanceCfg)
throws java.io.IOException
instance.cfg
Acquire the name of the modpack/instance of a MultiMC modpack from the modpacks instance.cfg, which is usually created by the MultiMC launcher.
instanceCfg - The config.json-file of the modpack to read.java.io.IOException - when the file could not be found or the properties not be loaded from the
file.@NotNull
public @NotNull java.lang.String getModLoaderCase(@NotNull
@NotNull java.lang.String modloader)
modloader - Modloader String-representation to normalize.public boolean checkConfiguration(@NotNull
@NotNull java.io.File configFile,
boolean quietCheck)
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.configFile - The configuration file to check. Must either be an existing file to load a
configuration from or null if you want to use the passed configuration
model.quietCheck - Whether the configuration should be printed to the console and logs. Pass
false to quietly check the configuration.false if the configuration has passed all tests.public boolean checkConfiguration(@NotNull
@NotNull java.io.File configFile,
@NotNull
@NotNull ConfigurationModel configurationModel,
boolean quietCheck)
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.configFile - The configuration file to check. Must either be an existing file to
load a configuration from or null if you want to use the passed
configuration model.configurationModel - Instance of a configuration of a modpack. Can be used to further
display or use any information within, as it may be changed or
otherwise altered by this method.quietCheck - Whether the configuration should be printed to the console and logs.
Pass false to quietly check the configuration.false if the configuration has passed all tests.public boolean checkConfiguration(@NotNull
@NotNull ConfigurationModel configurationModel,
boolean quietCheck)
ConfigurationModel. 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.configurationModel - Instance of a configuration of a modpack. Can be used to further
display or use any information within, as it may be changed or
otherwise altered by this method.quietCheck - Whether the configuration should be printed to the console and logs.
Pass false to quietly check the configuration.false if the configuration has passed all tests.public boolean checkModpackDir(@NotNull
@NotNull java.lang.String modpackDir)
modpackDir - The modpack directory.true if the directory exists.public boolean checkModpackDir(@NotNull
@NotNull java.lang.String modpackDir,
@NotNull
@NotNull java.util.List<java.lang.String> encounteredErrors)
modpackDir - Path to the modpack directory to check whether it is empty and whether
it is a directory.encounteredErrors - List to which all encountered errors are added to.true if the directory exists.public boolean checkCopyDirs(@NotNull
@NotNull java.util.List<java.lang.String> directoriesToCopy,
@NotNull
@NotNull java.lang.String modpackDir)
source/file;destination/file-combination, it is checked whether the
specified source-file exists on the host.directoriesToCopy - Directories, or source/file;destination/file-combinations, to
check for existence.
source/file;destination/file-combinations must be absolute
paths to the source-file.modpackDir - Path to the modpack directory in which to check for existence of the
passed list of directories.true if every directory was found in the modpack directory. If any single one
was not found, false is returned.public boolean checkModloaderVersion(@NotNull
@NotNull java.lang.String modloader,
@NotNull
@NotNull java.lang.String modloaderVersion,
@NotNull
@NotNull java.lang.String minecraftVersion)
modloader - The passed modloader which determines whether the check for Forge or
Fabric is called.modloaderVersion - The version of the modloader which is checked against the corresponding
modloaders manifest.minecraftVersion - The version of Minecraft used for checking the Forge version.true if the specified modloader version was found in the corresponding
manifest.@NotNull
public @NotNull java.util.List<java.lang.String> getAllFilesAndDirectoriesInModpackZip(@NotNull
@NotNull net.lingala.zip4j.ZipFile zipFile)
throws java.lang.IllegalArgumentException,
java.nio.file.FileSystemAlreadyExistsException,
java.nio.file.ProviderNotFoundException,
java.io.IOException,
java.lang.SecurityException
zipFile - The ZIP-archive to get the list of files from.java.lang.IllegalArgumentException - if the pre-conditions for the uri parameter are not
met, or the env parameter does not contain properties
required by the provider, or a property value is
invalid.java.nio.file.FileSystemAlreadyExistsException - if the file system has already been created.java.nio.file.ProviderNotFoundException - if a provider supporting the URI scheme is not
installed.java.io.IOException - if an I/O error occurs creating the file system.java.lang.SecurityException - if a security manager is installed, and it denies an
unspecified permission required by the file system
provider implementation.@NotNull
public @NotNull java.util.List<java.lang.String> getDirectoriesInModpackZip(@NotNull
@NotNull net.lingala.zip4j.ZipFile zipFile)
throws java.lang.IllegalArgumentException,
java.nio.file.FileSystemAlreadyExistsException,
java.nio.file.ProviderNotFoundException,
java.io.IOException,
java.lang.SecurityException
zipFile - The ZIP-archive to get the list of files from.java.lang.IllegalArgumentException - if the pre-conditions for the uri parameter are not
met, or the env parameter does not contain properties
required by the provider, or a property value is
invalid.java.nio.file.FileSystemAlreadyExistsException - if the file system has already been created.java.nio.file.ProviderNotFoundException - if a provider supporting the URI scheme is not
installed.java.io.IOException - if an I/O error occurs creating the file system.java.lang.SecurityException - if a security manager is installed, and it denies an
unspecified permission required by the file system
provider implementation.@NotNull
public @NotNull java.util.List<java.lang.String> getFilesInModpackZip(@NotNull
@NotNull net.lingala.zip4j.ZipFile zipFile)
throws java.lang.IllegalArgumentException,
java.nio.file.FileSystemAlreadyExistsException,
java.nio.file.ProviderNotFoundException,
java.io.IOException,
java.lang.SecurityException
zipFile - The ZIP-archive to get the list of files from.java.lang.IllegalArgumentException - if the pre-conditions for the uri parameter are not
met, or the env parameter does not contain properties
required by the provider, or a property value is
invalid.java.nio.file.FileSystemAlreadyExistsException - if the file system has already been created.java.nio.file.ProviderNotFoundException - if a provider supporting the URI scheme is not
installed.java.io.IOException - if an I/O error occurs creating the file system.java.lang.SecurityException - if a security manager is installed, and it denies an
unspecified permission required by the file system
provider implementation.