Class ServerPackProvisioner

  • All Implemented Interfaces:

    
    public final class ServerPackProvisioner
    
                        

    Provisioner for everything a server pack needs besides the modpack-files themselves: the server-icon, server.properties, start-scripts with variables.txt and HOW-TO-RUN.md, the ZIP-archive, the improved Fabric-launcher, installer-availability checks and pre-/post-install cleanups. Extracted from ServerPackHandler (refactor Phase 1d); ServerPackHandler remains the facade through which consumers access these operations.

    • Method Detail

      • getImprovedFabricLauncher

         final Unit getImprovedFabricLauncher(String minecraftVersion, String fabricVersion, String destination)

        Download and provide the improved Fabric Server Launcher, if it is available for the given Minecraft and Fabric version.

        Parameters:
        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.
      • copyIcon

         final Unit copyIcon(String destination, String pathToServerIcon)

        Copies the server-icon.png into server pack. The sever-icon is automatically scaled to a resolution of 64x64 pixels.

        Parameters:
        destination - The destination where the icon should be copied to.
        pathToServerIcon - The path to the custom server-icon.
      • copyProperties

         final Unit copyProperties(String destination, String pathToServerProperties)

        Copies the server.properties into server pack.

        Parameters:
        destination - The destination where the properties should be copied to.
        pathToServerProperties - The path to the custom server.properties.
      • createServerRunFiles

         final Unit createServerRunFiles(HashMap<String, String> scriptSettings, String destination, Boolean isLocal)

        Create start-scripts for the generated server pack using the templates the user has defined for their instance of ServerPackCreator.

        Parameters:
        scriptSettings - Key-value pairs to replace in the script.
        destination - The destination where the scripts should be created in.
        isLocal - Whether the start scripts should be created for a locally usable server pack.
      • zipBuilder

         final Optional<File> zipBuilder(String minecraftVersion, String destination, String modloader, String modloaderVersion)

        Creates a ZIP-archive of specified directory. Depending on the property de.griefed.serverpackcreator.serverpack.zip.exclude.enabled, files will be excluded. To customize the files which will be excluded, the property de.griefed.serverpackcreator.serverpack.zip.exclude must be configured accordingly. The created ZIP-archive will be stored alongside the specified destination, with _server_pack.zip appended to its name.

        Parameters:
        minecraftVersion - Determines the name of the Minecraft server JAR to exclude from the ZIP-archive if the modloader is Forge.
        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.
      • preInstallationCleanup

         final Unit preInstallationCleanup(String destination)

        Delete files and folders from previous installations to prevent errors during server installation due to already existing files.

        Parameters:
        destination - The folder in which to perform the cleanup operations.
      • serverDownloadable

         final Boolean serverDownloadable(String mcVersion, String modloader, String modloaderVersion)

        Check whether the installer for the given combination of Minecraft version, modloader and modloader version is available/reachable.

        Parameters:
        mcVersion - The Minecraft version.
        modloader - The modloader.
        modloaderVersion - The modloader version.
        Returns:

        true if the installer can be downloaded.

      • postInstallCleanup

         final Unit postInstallCleanup(String destination)

        Cleans up the server_pack directory by deleting left-over files from modloader installations and version checking.

        Parameters:
        destination - The destination where we should clean up in.