@Component
public final class ConfigurationHandler
extends java.lang.Object
ConfigurationModel
so it can safely be used in ServerPackHandler.run(ConfigurationModel) later.| Constructor and Description |
|---|
ConfigurationHandler(I18n injectedI18n,
VersionMeta injectedVersionMeta,
ApplicationProperties injectedApplicationProperties,
Utilities injectedUtilities,
ConfigUtilities injectedConfigUtilities,
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(java.util.List<java.lang.String> directoriesToCopy,
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(java.util.List<java.lang.String> directoriesToCopy,
java.lang.String modpackDir,
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(java.lang.String iconOrPropertiesPath)
Checks the passed String whether it is an existing file.
|
boolean |
checkJavaPath(java.lang.String pathToJava)
Deprecated.
Will be removed in Milestone 4. Java path settings have moved to the global
ApplicationProperties, because the Java path setting is used for modloader installation by
ServerPackCreator only.
|
java.lang.String |
checkManifests(java.lang.String destination,
ConfigurationModel configurationModel,
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(java.lang.String modloader)
Checks whether either Forge or Fabric were specified as the modloader.
|
boolean |
checkModloaderVersion(java.lang.String modloader,
java.lang.String modloaderVersion,
java.lang.String minecraftVersion)
Check the given Minecraft and modloader versions for the specified modloader.
|
boolean |
checkModloaderVersion(java.lang.String modloader,
java.lang.String modloaderVersion,
java.lang.String minecraftVersion,
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(java.lang.String modpackDir)
Check the passed directory for existence and whether it is a directory, rather than a file.
|
boolean |
checkModpackDir(java.lang.String modpackDir,
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 |
checkZipArchive(java.nio.file.Path pathToZip,
java.util.List<java.lang.String> encounteredErrors)
Check a given ZIP-archives contents.
|
void |
ensureScriptSettingsDefaults(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
|
java.lang.String |
getJavaPath(java.lang.String pathToJava)
Deprecated.
Will be removed in Milestone 4. Java path settings have moved to the global
ApplicationProperties, because the Java path setting is used for modloader installation by
ServerPackCreator only.
|
boolean |
isDir(ConfigurationModel configurationModel,
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(ConfigurationModel configurationModel,
java.util.List<java.lang.String> encounteredErrors)
Checks the specified ZIP-archive for validity.
|
void |
sanitizeLinks(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. |
boolean |
testJava(java.lang.String pathToJava)
Deprecated.
Will be removed in Milestone 4. Java path settings have moved to the global
ApplicationProperties, because the Java path setting is used for modloader installation by
ServerPackCreator only.
|
@Autowired public ConfigurationHandler(I18n injectedI18n, VersionMeta injectedVersionMeta, ApplicationProperties injectedApplicationProperties, Utilities injectedUtilities, ConfigUtilities injectedConfigUtilities, ApplicationAddons injectedApplicationAddons) throws java.io.IOException
injectedI18n - Instance of I18n required for localized log
messages.injectedApplicationProperties - Instance of ApplicationProperties required for
various different things.injectedVersionMeta - Instance of VersionMeta required for everything
version-related.injectedUtilities - Instance of Utilities.injectedConfigUtilities - Instance of ConfigUtilities.injectedApplicationAddons - Instance of ApplicationAddons.java.io.IOException - if the VersionMeta could not be instantiated.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,
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 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 boolean isDir(ConfigurationModel configurationModel, 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(ConfigurationModel configurationModel, 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 java.lang.String checkManifests(java.lang.String destination,
ConfigurationModel configurationModel,
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 boolean checkZipArchive(java.nio.file.Path pathToZip,
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.public void ensureScriptSettingsDefaults(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 void sanitizeLinks(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 checkModpackDir(java.lang.String modpackDir)
modpackDir - The modpack directory.public boolean checkModpackDir(java.lang.String modpackDir,
java.util.List<java.lang.String> encounteredErrors)
modpackDir - String. The path to the modpack directory to check whether it is empty
and whether it is a directory.encounteredErrors - List String. A list to which all encountered errors are saved to.public boolean checkCopyDirs(java.util.List<java.lang.String> directoriesToCopy,
java.lang.String modpackDir)
source/file;destination/file-combination, it is checked whether the
specified source-file exists on the host.directoriesToCopy - List String. 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 - String. The path to the modpack directory in which to check for
existence of the passed list of directories.public boolean checkCopyDirs(java.util.List<java.lang.String> directoriesToCopy,
java.lang.String modpackDir,
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 - List String. 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 - String. The path to the modpack directory in which to check for
existence of the passed list of directories.encounteredErrors - List String. A list to which all encountered errors are saved to.public boolean checkIconAndProperties(java.lang.String iconOrPropertiesPath)
iconOrPropertiesPath - The path to the custom server-icon.png or server.properties file to
check.@Deprecated public boolean checkJavaPath(java.lang.String pathToJava)
pathToJava - Path to the Java executabletrue if the path is valid.@Deprecated public boolean testJava(java.lang.String pathToJava)
java -version. If the command goes
through without errors, it is considered a correct specification.pathToJava - Path to the java executable/binary.true if the specified file is a valid Java executable/binary.@Deprecated public java.lang.String getJavaPath(java.lang.String pathToJava)
pathToJava - The path to check for whether it is a valid Java installation.public boolean checkModloader(java.lang.String modloader)
modloader - Check as case-insensitive for Forge or Fabric.public boolean checkModloaderVersion(java.lang.String modloader,
java.lang.String modloaderVersion,
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.public boolean checkModloaderVersion(java.lang.String modloader,
java.lang.String modloaderVersion,
java.lang.String minecraftVersion,
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.