@Component
public final class ServerPackHandler
extends java.lang.Object
ConfigurationModel and run it through any of the available
ConfigurationHandler.checkConfiguration(ConfigurationModel, boolean)-variants, and then
call run(ConfigurationModel) with the previously checked configuration model. You may
run with an unchecked configuration model, but no guarantees or promises, yes not even support,
is given for running a model without checking it first.cleanupEnvironment(boolean, ConfigurationModel) and cleanupEnvironment(boolean, String) ApplicationAddons.runPreZipExtensions(ConfigurationModel, String)copyFiles(ConfigurationModel) and copyFiles(String, List, List, String, String, String)provideImprovedFabricServerLauncher(ConfigurationModel) and provideImprovedFabricServerLauncher(String, String, String) if Fabric is the chosen ModloadercopyIcon(ConfigurationModel) and copyIcon(String, String)copyProperties(ConfigurationModel) and copyProperties(String, String)ApplicationAddons.runPreZipExtensions(ConfigurationModel, String)zipBuilder(ConfigurationModel) and zipBuilder(String, boolean, String, String, String)createStartScripts(ConfigurationModel, boolean) and createStartScripts(HashMap, String, boolean)installServer(ConfigurationModel) and installServer(String, String, String, String)ApplicationAddons.runPostGenExtensions(ConfigurationModel, String)ApplicationAddons.runPreGenExtensions(ConfigurationModel, String)},
ApplicationAddons.runPreZipExtensions(ConfigurationModel, String)} and
ApplicationAddons.runPostGenExtensions(ConfigurationModel, String).| Constructor and Description |
|---|
ServerPackHandler(@NotNull ApplicationProperties injectedApplicationProperties,
@NotNull VersionMeta injectedVersionMeta,
@NotNull Utilities injectedUtilities,
@NotNull ApplicationAddons injectedApplicationAddons,
@NotNull ModScanner injectedModScanner)
Create a new instance to create server packs.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cleanupEnvironment(boolean deleteZip,
@NotNull ConfigurationModel configurationModel)
Deletes all files, directories and ZIP-archives of previously generated server packs to ensure
newly generated server pack is as clean as possible.
|
void |
cleanupEnvironment(boolean deleteZip,
@NotNull java.lang.String destination)
Deletes all files, directories and ZIP-archives of previously generated server packs to ensure
newly generated server pack is as clean as possible.
|
void |
copyFiles(@NotNull ConfigurationModel configurationModel)
Copies all specified directories and mods, excluding clientside-only mods, from the modpack
directory into the server pack directory.
|
void |
copyFiles(@NotNull java.lang.String modpackDir,
@NotNull java.util.List<java.lang.String> directoriesToCopy,
@NotNull java.util.List<java.lang.String> clientMods,
@NotNull java.lang.String minecraftVersion,
@NotNull java.lang.String destination,
@NotNull java.lang.String modloader)
Copies all specified directories and mods, excluding clientside-only mods, from the modpack
directory into the server pack directory.
|
void |
copyIcon(@NotNull ConfigurationModel configurationModel)
Copies the server-icon.png into server pack.
|
void |
copyIcon(@NotNull java.lang.String destination,
@NotNull java.lang.String pathToServerIcon)
Copies the server-icon.png into server pack.
|
void |
copyProperties(@NotNull ConfigurationModel configurationModel)
Copies the server.properties into server pack.
|
void |
copyProperties(@NotNull java.lang.String destination,
@NotNull java.lang.String pathToServerProperties)
Copies the server.properties into server pack.
|
void |
createStartScripts(@NotNull ConfigurationModel configurationModel,
boolean isLocal)
Create start-scripts for the generated server pack using the templates the user has defined for
their instance of ServerPackCreator in
ApplicationProperties.scriptTemplates(). |
void |
createStartScripts(@NotNull java.util.HashMap<java.lang.String,java.lang.String> scriptSettings,
@NotNull java.lang.String destination,
boolean isLocal)
Create start-scripts for the generated server pack using the templates the user has defined for
their instance of ServerPackCreator in
ApplicationProperties.scriptTemplates(). |
@NotNull java.util.List<java.io.File> |
getModsToInclude(@NotNull ConfigurationModel configurationModel)
Generates a list of all mods to include in the server pack.
|
@NotNull java.util.List<java.io.File> |
getModsToInclude(@NotNull java.lang.String modsDir,
@NotNull java.util.List<java.lang.String> userSpecifiedClientMods,
@NotNull java.lang.String minecraftVersion,
@NotNull java.lang.String modloader)
Generates a list of all mods to include in the server pack.
|
@NotNull java.lang.String |
getServerPackDestination(@NotNull ConfigurationModel configurationModel)
Acquire the destination directory in which the server pack will be generated.
|
void |
installServer(@NotNull ConfigurationModel configurationModel)
Installs the modloader server for the specified modloader, modloader version and Minecraft
version.
|
void |
installServer(@NotNull java.lang.String modLoader,
@NotNull java.lang.String minecraftVersion,
@NotNull java.lang.String modLoaderVersion,
@NotNull java.lang.String destination)
Installs the modloader server for the specified modloader, modloader version and Minecraft
version.
|
void |
provideImprovedFabricServerLauncher(@NotNull ConfigurationModel configurationModel)
Download and provide the improved Fabric Server Launcher, if it is available for the given
Minecraft and Fabric version.
|
void |
provideImprovedFabricServerLauncher(@NotNull java.lang.String minecraftVersion,
@NotNull java.lang.String fabricVersion,
@NotNull java.lang.String destination)
Download and provide the improved Fabric Server Launcher, if it is available for the given
Minecraft and Fabric version.
|
boolean |
run(@NotNull ConfigurationModel configurationModel)
Create a server pack from a given instance of
ConfigurationModel. |
@NotNull ServerPackModel |
run(@NotNull ServerPackModel serverPackModel)
Create a server pack from a given instance of
ServerPackModel when running as a
webservice. |
boolean |
serverDownloadable(@NotNull java.lang.String mcVersion,
@NotNull java.lang.String modloader,
@NotNull java.lang.String modloaderVersion)
Check whether the installer for the given combination of Minecraft version, modloader and
modloader version is available/reachable.
|
void |
zipBuilder(@NotNull ConfigurationModel configurationModel)
Creates a ZIP-archive of the server pack previously generated.
|
void |
zipBuilder(@NotNull java.lang.String minecraftVersion,
boolean includeServerInstallation,
@NotNull java.lang.String destination,
@NotNull java.lang.String modloader,
@NotNull java.lang.String modloaderVersion)
Creates a ZIP-archive of specified directory.
|
@Autowired
public ServerPackHandler(@NotNull
@NotNull ApplicationProperties injectedApplicationProperties,
@NotNull
@NotNull VersionMeta injectedVersionMeta,
@NotNull
@NotNull Utilities injectedUtilities,
@NotNull
@NotNull ApplicationAddons injectedApplicationAddons,
@NotNull
@NotNull ModScanner injectedModScanner)
injectedApplicationProperties - Base settings of ServerPackCreator needed for server pack
generation, such as access to the directories, script
templates and so on.injectedVersionMeta - Meta for modloader and version specific checks and
information gathering, such as modloader installer
downloads.injectedUtilities - Common utilities used across ServerPackCreator.injectedApplicationAddons - Any addons which a user may want to execute during the
generation of a server pack.injectedModScanner - In case a user enabled automatic sideness detection, this
will exclude clientside-only mods from a server pack.@NotNull public @NotNull ServerPackModel run(@NotNull @NotNull ServerPackModel serverPackModel)
ServerPackModel when running as a
webservice.serverPackModel - An instance of ServerPackModel which contains the configuration
of the modpack.ServerPackModel which got altered during the creation of said server
pack.@NotNull
public @NotNull java.lang.String getServerPackDestination(@NotNull
@NotNull ConfigurationModel configurationModel)
Survive Create Prosper 4 - 5.0.1 would become Survive_Create_Prosper_4_-_5.0.1
Even though it is the year 2022, spaces in paths can and do still cause trouble. Such as for
Powershell scripts. Powershell throws a complete fit if the path contains spaces....soooooo, we
remove them. Better safe than sorry.configurationModel - Model containing the modpack directory of the modpack from which the
server pack will be generated.public boolean run(@NotNull
@NotNull ConfigurationModel configurationModel)
ConfigurationModel.configurationModel - An instance of ConfigurationModel which contains the
configuration of the modpack from which the server pack is to be
created.true if the server pack was successfully generated.public void cleanupEnvironment(boolean deleteZip,
@NotNull
@NotNull java.lang.String destination)
deleteZip - Whether to delete the server pack ZIP-archive.destination - The destination at which to clean up in.public void copyFiles(@NotNull
@NotNull ConfigurationModel configurationModel)
source/file;destination/file
-combination is provided, the specified source-file is copied to the specified
destination-file. One of the reasons as to why it is recommended to run a given
ConfigurationModel through the ConfigurationHandler first, is because the ConfigurationHandler
will resolve links to their actual files first before then correcting the given
ConfigurationModel.configurationModel - ConfigurationModel containing the modpack directory, list of
directories and files to copy, list of clientside-only mods to
exclude, the Minecraft version used by the modpack and server pack,
and the modloader used by the modpack and server pack.public void provideImprovedFabricServerLauncher(@NotNull
@NotNull ConfigurationModel configurationModel)
configurationModel - ConfigurationModel containing the Minecraft and Fabric version for
which to acquire the improved Fabric Server Launcher.public void copyIcon(@NotNull
@NotNull ConfigurationModel configurationModel)
configurationModel - Containing the modpack directory to acquire the destination of the
server pack and the path to the server icon to copy.public void copyProperties(@NotNull
@NotNull ConfigurationModel configurationModel)
configurationModel - Containing the modpack directory to acquire the destination of the
server pack and the path to the server properties to copy.public void createStartScripts(@NotNull
@NotNull ConfigurationModel configurationModel,
boolean isLocal)
ApplicationProperties.scriptTemplates().configurationModel - Configuration model containing modpack specific values. keys to be
replaced with their respective values in the start scripts, as well
as the modpack directory from which the destination of the server
pack is acquired.isLocal - Whether the start scripts should be created for a locally usable
server pack. Use false if the start scripts should be created
for a server pack about to be zipped.public void zipBuilder(@NotNull
@NotNull ConfigurationModel configurationModel)
ApplicationProperties.isZipFileExclusionEnabled(), files will be excluded. To customize
the files which will be excluded, see
ApplicationProperties.getFilesToExcludeFromZipArchive()configurationModel - Contains the Minecraft version used by the modpack and server pack,
whether the modloader server was installed, the modpack directory to
acquire the destination of the server pack, the modloader used by the
modpack and server pack and the modloader version.public void installServer(@NotNull
@NotNull ConfigurationModel configurationModel)
configurationModel - Contains the used modloader, Minecraft version, modloader version,
path to the java executable/binary and modpack directory in order to
acquire the destination at which to install the server.public void copyFiles(@NotNull
@NotNull java.lang.String modpackDir,
@NotNull
@NotNull java.util.List<java.lang.String> directoriesToCopy,
@NotNull
@NotNull java.util.List<java.lang.String> clientMods,
@NotNull
@NotNull java.lang.String minecraftVersion,
@NotNull
@NotNull java.lang.String destination,
@NotNull
@NotNull java.lang.String modloader)
source/file;destination/file
-combination is provided, the specified source-file is copied to the specified
destination-file. One of the reasons as to why it is recommended to run a given
ConfigurationModel through the ConfigurationHandler first, is because the ConfigurationHandler
will resolve links to their actual files first before then correcting the given
ConfigurationModel.modpackDir - Files and directories are copied into the server_pack directory inside
the modpack directory.directoriesToCopy - All directories and files therein to copy to the server pack.clientMods - List of clientside-only mods to exclude from the server pack.minecraftVersion - The Minecraft version the modpack uses.destination - The destination where the files should be copied to.modloader - The modloader used for mod sideness detection.public void provideImprovedFabricServerLauncher(@NotNull
@NotNull java.lang.String minecraftVersion,
@NotNull
@NotNull java.lang.String fabricVersion,
@NotNull
@NotNull java.lang.String destination)
minecraftVersion - The Minecraft version the modpack uses and the Fabric Server Launcher
should be downloaded for.fabricVersion - The modloader version the modpack uses and the Fabric Server Launcher
should be downloaded for.destination - The destination of the server pack.public void copyIcon(@NotNull
@NotNull java.lang.String destination,
@NotNull
@NotNull java.lang.String pathToServerIcon)
destination - The destination where the icon should be copied to.pathToServerIcon - The path to the custom server-icon.public void copyProperties(@NotNull
@NotNull java.lang.String destination,
@NotNull
@NotNull java.lang.String pathToServerProperties)
destination - The destination where the properties should be copied to.pathToServerProperties - The path to the custom server.properties.public void createStartScripts(@NotNull
@NotNull java.util.HashMap<java.lang.String,java.lang.String> scriptSettings,
@NotNull
@NotNull java.lang.String destination,
boolean isLocal)
ApplicationProperties.scriptTemplates().scriptSettings - Key-value pairs to replace in the script. A given key in the script is
replaced with its value.destination - The destination where the scripts should be created in.isLocal - Whether the start scripts should be created for a locally usable server
pack. Use false if the start scripts should be created for a
server pack about to be zipped.public void zipBuilder(@NotNull
@NotNull java.lang.String minecraftVersion,
boolean includeServerInstallation,
@NotNull
@NotNull java.lang.String destination,
@NotNull
@NotNull java.lang.String modloader,
@NotNull
@NotNull java.lang.String modloaderVersion)
ApplicationProperties.isZipFileExclusionEnabled(), files will be excluded. To customize
the files which will be excluded, see
ApplicationProperties.getFilesToExcludeFromZipArchive(). The created ZIP-archive will
be stored alongside the specified destination, with _server_pack.zip appended to its
name.minecraftVersion - Determines the name of the Minecraft server JAR to exclude
from the ZIP-archive if the modloader is Forge.includeServerInstallation - Determines whether the Minecraft server JAR info should be
printed.destination - The destination where the ZIP-archive should be created in.modloader - The modloader the modpack and server pack use.modloaderVersion - The modloader version the modpack and server pack use.public void installServer(@NotNull
@NotNull java.lang.String modLoader,
@NotNull
@NotNull java.lang.String minecraftVersion,
@NotNull
@NotNull java.lang.String modLoaderVersion,
@NotNull
@NotNull java.lang.String destination)
modLoader - The modloader for which to install the server software. Either Forge or
Fabric.minecraftVersion - The Minecraft version for which to install the modloader and Minecraft
server.modLoaderVersion - The modloader version for which to install the modloader and Minecraft
server.destination - The destination where the modloader server should be installed into.@NotNull
public @NotNull java.util.List<java.io.File> getModsToInclude(@NotNull
@NotNull java.lang.String modsDir,
@NotNull
@NotNull java.util.List<java.lang.String> userSpecifiedClientMods,
@NotNull
@NotNull java.lang.String minecraftVersion,
@NotNull
@NotNull java.lang.String modloader)
modsDir - String. The mods-directory of the modpack of which to generate a
list of all its contents.userSpecifiedClientMods - List String. A list of all clientside-only mods.minecraftVersion - String. The Minecraft version the modpack uses. When the
modloader is Forge, this determines whether Annotations or Tomls
are scanned.modloader - String The modloader the modpack uses.public boolean serverDownloadable(@NotNull
@NotNull java.lang.String mcVersion,
@NotNull
@NotNull java.lang.String modloader,
@NotNull
@NotNull java.lang.String modloaderVersion)
mcVersion - The Minecraft version.modloader - The modloader.modloaderVersion - The modloader version.true if the installer can be downloaded.public void cleanupEnvironment(boolean deleteZip,
@NotNull
@NotNull ConfigurationModel configurationModel)
deleteZip - Whether to delete the server pack ZIP-archive.configurationModel - ConfigurationModel containing the modpack directory from which the
destination of the server pack is acquired.@NotNull
public @NotNull java.util.List<java.io.File> getModsToInclude(@NotNull
@NotNull ConfigurationModel configurationModel)
configurationModel - The configurationModel containing the modpack directory, list of
clientside-only mods to exclude, Minecraft version used by the
modpack and server pack and the modloader used by the modpack and
server pack.