Class ModDependencyInstaller
- Namespace
- McServerLauncher.Services
- Assembly
- McServerLauncher.dll
Finds the library mods a server's content needs and puts them on disk.
public sealed class ModDependencyInstaller
- Inheritance
-
ModDependencyInstaller
- Inherited Members
Remarks
Three callers want it and each shows progress somewhere different: the install banner while a mod is being installed, the line under the installed list for "install the missing ones", and the server's console when a start finds something missing. So this class says what it is doing to an IProgress<T> it is handed and never decides where that goes.
It holds no UI and no token of its own: every call that can wait takes the caller's.
Constructors
ModDependencyInstaller(ServerConfig, ModrinthService, ModDependencyService, InstalledContentIndex)
public ModDependencyInstaller(ServerConfig config, ModrinthService store, ModDependencyService dependencies, InstalledContentIndex index)
Parameters
configServerConfigThe server whose content folder is being completed.
storeModrinthServiceWhere the libraries are downloaded from.
dependenciesModDependencyServiceDecides what is missing; shares the store's HTTP client and cache.
indexInstalledContentIndexWhat the store says each installed jar is.
Methods
FindMissingAsync(IEnumerable<string>, IEnumerable<string>, CancellationToken)
Looks for library mods that the installed ones need and that nobody installed.
public Task<ModDependencyService.Plan?> FindMissingAsync(IEnumerable<string> sha1Hashes, IEnumerable<string> installedFiles, CancellationToken ct)
Parameters
sha1HashesIEnumerable<string>The hashes of the installed jars.
installedFilesIEnumerable<string>The installed jars, for the ids they declare themselves.
ctCancellationTokenCancels the lookups.
Returns
- Task<ModDependencyService.Plan>
What is missing, or null when the store knows none of the installed jars.
Remarks
Runs off the hashes the update check already computed, so it costs one extra request. It exists for the servers that were built before the installer started pulling dependencies in: those fail at start-up with the loader listing what is missing, and there is nothing in the app that would otherwise say so.
InstallByIdAsync(IEnumerable<string>, IProgress<string>?, CancellationToken)
Fetches the mods or plugins named by ids, for the check before a start.
public Task<bool> InstallByIdAsync(IEnumerable<string> ids, IProgress<string>? log, CancellationToken ct)
Parameters
idsIEnumerable<string>logIProgress<string>ctCancellationToken
Returns
Remarks
The ids come from the jars, and a mod id is not a store id: cristallib is published on
Modrinth as cristel-lib, and there is no rule that maps one to the other. So anything
the store does not recognise is skipped rather than reported as an error — the caller checks
again afterwards and says what is still missing, which is the honest answer.
InstallForAsync(VersionResult, string, string, bool, IProgress<string>, CancellationToken)
Installs the required dependencies of version that are not there yet.
public Task<(int Installed, IReadOnlyList<string> Unresolved)> InstallForAsync(VersionResult version, string jarPath, string folder, bool forPlayerPack, IProgress<string> progress, CancellationToken ct = default)
Parameters
versionVersionResultjarPathstringfolderstringforPlayerPackboolprogressIProgress<string>ctCancellationToken
Returns
- Task<(int Installed, IReadOnlyList<string> Unresolved)>
How many were installed, and any that could not be resolved at all. Zero and empty is the normal answer for a plugin or for a library mod that depends on nothing.
Remarks
forPlayerPack is true when folder is the players' pack.
A library the server already has (Fabric API, nearly always) satisfies the mod and is not
downloaded again; one that is only in the pack does not satisfy a server mod, which is why
this goes one way.
InstallListedAsync(IReadOnlyList<Needed>, IProgress<string>, CancellationToken)
Downloads libraries the scan already found missing, saying which one is under way.
public Task InstallListedAsync(IReadOnlyList<ModDependencyService.Needed> missing, IProgress<string> progress, CancellationToken ct)
Parameters
missingIReadOnlyList<ModDependencyService.Needed>progressIProgress<string>ctCancellationToken