@Component
public class ConfigurationHandler
extends java.lang.Object
ConfigurationModel
so it can safely be used in ServerPackHandler.run(ConfigurationModel) later.| Constructor and Description |
|---|
ConfigurationHandler(LocalizationManager injectedLocalizationManager,
VersionMeta injectedVersionMeta,
ApplicationProperties injectedApplicationProperties,
Utilities injectedUtilities,
ConfigUtilities injectedConfigUtilities)
Constructor
|
| 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)
Check whether the given path is a valid Java specification.
|
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 |
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.
|
java.lang.String |
getJavaPath(java.lang.String pathToJava)
Check the given path to a Java installation for validity and return it, if it is valid.
|
boolean |
testJava(java.lang.String pathToJava)
Test for a valid Java specification by trying to run
java -version. |
@Autowired public ConfigurationHandler(LocalizationManager injectedLocalizationManager, VersionMeta injectedVersionMeta, ApplicationProperties injectedApplicationProperties, Utilities injectedUtilities, ConfigUtilities injectedConfigUtilities) throws java.io.IOException
Used for Dependency Injection.
Receives an instance of LocalizationManager or creates one if the received one is
null. Required for use of localization.
injectedLocalizationManager - Instance of LocalizationManager required for
localized log messages.injectedApplicationProperties - Instance of Properties required for various
different things.injectedVersionMeta - Instance of VersionMeta required for everything
version-related.injectedUtilities - Instance of Utilities.injectedConfigUtilities - Instance of ConfigUtilities.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 - File. 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 - List String. 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 - Boolean. 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 - File. 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 - Boolean. 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 - File. 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 - 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 - Boolean. 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 - 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 - Boolean. 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 - File. 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 - 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 - List String. 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 - Boolean. 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 - 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 - List String. 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 - Boolean. 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 checkZipArchive(java.nio.file.Path pathToZip,
java.util.List<java.lang.String> encounteredErrors)
pathToZip - Path to the ZIP-file to check.encounteredErrors - String List. List of encountered errors for further processing, like
printing to logs or display in GUI or whatever you want, really.public boolean checkModpackDir(java.lang.String modpackDir)
modpackDir - String 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 - String. The path to the custom server-icon.png or server.properties
file to check.public boolean checkJavaPath(java.lang.String pathToJava)
pathToJava - String Path to the Java executabletrue if the path is valid.public boolean testJava(java.lang.String pathToJava)
java -version. If the command
goes through without errors, it is considered a correct specification.pathToJava - String Path to the java executable/binary.Boolean true if the specified file is a valid Java
executable/binary.public java.lang.String getJavaPath(java.lang.String pathToJava)
pathToJava - String. The path to check for whether it is a valid Java installation.public boolean checkModloader(java.lang.String modloader)
modloader - String. Check as case-insensitive for Forge or Fabric.public boolean checkModloaderVersion(java.lang.String modloader,
java.lang.String modloaderVersion,
java.lang.String minecraftVersion)
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.