Class ModpackManifestParser

  • All Implemented Interfaces:

    
    public final class ModpackManifestParser
    
                        

    Parser deriving PackConfig-values from the manifests of various launchers: CurseForge (manifest.json, minecraftinstance.json), Modrinth (modrinth.index.json), ATLauncher (instance.json), GDLauncher (config.json, instance.json) and MultiMC/Prism (mmc-pack.json, instance.cfg), including modloader-name normalization. Extracted from ConfigurationHandler (refactor Phase 1c); ConfigurationHandler remains the facade through which consumers access these parsers.

    • Method Detail

      • manifestCandidates

         final List<File> manifestCandidates(String destination)

        Every launcher-manifest checkManifests looks for, whether or not the file exists.

        Ordered as checkManifests consults them — most-specific launcher first — with one wrinkle worth knowing: the last entry, MultiMC/Prism's instance.cfg, is read inside the mmc-pack.json branch rather than being a candidate in its own right, so it is listed last but never selects a launcher by itself.

        The single source of truth for "which files define this modpack". checkManifests builds its own candidates from this, so a caller wanting to know whether a modpack's manifests have changed — the GUI's editor does, to avoid re-parsing a multi-megabyte minecraftinstance.json on every keystroke-pause — can ask instead of duplicating the list and drifting from it.

        Parameters:
        destination - The directory the modpack lives in.
        Returns:

        The candidate manifest files, existing or not, most-specific launcher first.

      • checkManifests

         final String checkManifests(String destination, PackConfig packConfig, ConfigCheck configCheck)

        Check whether various manifests from various launchers exist and use them to update our ConfigurationModel and pack name.

        Parameters:
        destination - The destination in which the manifests are.
        packConfig - The ConfigurationModel to update.
        configCheck - Collection of encountered errors, if any, for convenient result-checks.
        Returns:

        The name of the modpack currently being checked. null if the name could not be acquired.

      • updateConfigModelFromCurseManifest

         final Unit updateConfigModelFromCurseManifest(PackConfig packConfig, File manifest)

        manifest.json

        Update the given ConfigurationModel with values gathered from the downloaded CurseForge modpack. A manifest.json-file is usually created when a modpack is exported through launchers like Overwolf's CurseForge or GDLauncher.

        Parameters:
        packConfig - An instance containing a configuration for a modpack from which to create a server pack.
        manifest - The CurseForge manifest.json-file of the modpack to read.
      • updatePackName

         final String updatePackName(PackConfig packConfig, String childNodes)

        Acquire the modpacks name from the JSON previously acquired and stored in the ConfigurationModel.

        Parameters:
        packConfig - The ConfigurationModel containing the JsonNode from which to acquire the modpacks name.
        childNodes - The child nodes, in order, which contain the requested packname.
        Returns:

        The new name of the modpack.

      • updateConfigModelFromMinecraftInstance

         final Unit updateConfigModelFromMinecraftInstance(PackConfig packConfig, File minecraftInstance)

        minecraftinstance.json

        Update the given ConfigurationModel with values gathered from the minecraftinstance.json of the modpack. A minecraftinstance.json is usually created by Overwolf's CurseForge launcher.

        Parameters:
        packConfig - An instance containing a configuration for a modpack from which to create a server pack.
        minecraftInstance - The minecraftinstance.json-file of the modpack to read.
      • updateConfigModelFromModrinthManifest

         final Unit updateConfigModelFromModrinthManifest(PackConfig packConfig, File manifest)

        modrinth.index.json

        Update the given ConfigurationModel with values gathered from a Modrinth modrinth.index.json-manifest.

        Parameters:
        packConfig - The model to update.
        manifest - The manifest file.
      • updateConfigModelFromATLauncherInstance

         final Unit updateConfigModelFromATLauncherInstance(PackConfig packConfig, File manifest)

        instance.json

        Update the given ConfigurationModel with values gathered from a ATLauncher manifest.

        Parameters:
        packConfig - The model to update.
        manifest - The manifest file.
      • updateConfigModelFromConfigJson

         final Unit updateConfigModelFromConfigJson(PackConfig packConfig, File config)

        config.json

        Update the given ConfigurationModel with values gathered from the modpacks config.json. A config.json is usually created by GDLauncher.

        Parameters:
        packConfig - An instance containing a configuration for a modpack from which to create a server pack.
        config - The config.json-file of the modpack to read.
      • updateConfigModelFromGDInstanceJson

         final Unit updateConfigModelFromGDInstanceJson(PackConfig packConfig, File instance)

        parentDirectory/instance.json

        Update the given PackConfig with values gathered from the modpacks instance.json. An instance.json is usually created by GDLauncher and located in the modpacks parent directory of the data-directory.

        Parameters:
        packConfig - An instance containing a configuration for a modpack from which to create a server pack.
        instance - The instance.json-file of the modpack to read.
      • updateConfigModelFromMMCPack

         final Unit updateConfigModelFromMMCPack(PackConfig packConfig, File mmcPack)

        mmc-pack.json

        Update the given ConfigurationModel with values gathered from the modpacks mmc-pack.json. A mmc-pack.json is usually created by the MultiMC launcher.

        Parameters:
        packConfig - An instance containing a configuration for a modpack from which to create a server pack.
        mmcPack - The config.json-file of the modpack to read.
      • updateDestinationFromInstanceCfg

         final String updateDestinationFromInstanceCfg(File instanceCfg)

        instance.cfg

        Acquire the name of the modpack/instance of a MultiMC modpack from the modpacks instance.cfg, which is usually created by the MultiMC launcher.

        Parameters:
        instanceCfg - The config.json-file of the modpack to read.
        Returns:

        The instance name.

      • getModLoaderCase

         final String getModLoaderCase(String modloader)

        Ensures the modloader is normalized to first letter upper case and rest lower case. Basically allows the user to input Forge or Fabric in any combination of upper- and lowercase and ServerPackCreator will still be able to work with the users input.

        Parameters:
        modloader - Modloader String-representation to normalize.
        Returns:

        A normalized String of the specified modloader.