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. ServerPackHandler remains the facade through which consumers access these operations.

    • Method Detail

      • getVariables

         final String getVariables()

        The variables.txt content for a generated server pack, still carrying its SPC_..._SPC placeholders.

        Read from the shipped template in SPC's server_files-directory (ApiProperties.defaultVariablesTemplate) so the operator-facing text — the comments explaining every setting — can be corrected without rebuilding the API, exactly like the start-script templates next to it. Falls back to the copy bundled in the jar when that file is absent, which keeps the API usable before ApiWrapper.setup() has populated the home-directory.

      • getServerRunFileNames

         final List<String> getServerRunFileNames()

        Every file createServerRunFiles writes, by name, relative to the server pack. Read by the manifest so its record of the pack covers the run-files too, and derived from the very template-maps the creation iterates, so the two cannot end up listing different things.

      • 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.

        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.

        destination — The destination where the icon should be copied to. pathToServerIcon — The path to the custom server-icon.

      • zipBuilder

        @JvmOverloads() final Optional<File> zipBuilder(String minecraftVersion, String destination, String modloader, String modloaderVersion, Function1<File, Boolean> isExcluded)

        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.

      • zipBuilder

        @JvmOverloads() 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.

      • preInstallationCleanup

         final Unit preInstallationCleanup(String destination)

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

        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.

        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.

        destination — The destination where we should clean up in.

      • replacePlaceholders

         final String replacePlaceholders(Boolean isLocal, String content, HashMap<String, String> scriptSettings)

        Replace placeholders for script settings in the given content with their respective values, both provided via the HashMap scriptSettings.

        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.