public ModLoaderManager(IMinecraftInstance mcInstnace) { mcInstance = mcInstnace; modLoaders = new List <ModLoaderInfo>(); ModLoaders = modLoaders.AsReadOnly(); compatibleSchemata = InstalationSchemas.Where(s => s.IsCompatible(mcInstnace)).ToArray(); foreach (IModLoaderHandler handler in compatibleSchemata) { handler.DetectModLoaders(mcInstnace, modLoaders); } Logger.Debug($"Detected mod loaders for instance {mcInstnace.GetType()} with name {mcInstance.Name}: {JsonConvert.SerializeObject(ModLoaders, Formatting.Indented)}"); }
public override bool IsCompatible(IMinecraftInstance instance) { return(instance.GetType() == typeof(TInstance)); }
public void Install(string name, string version) { IModLoaderHandler schema = compatibleSchemata.FirstOrDefault(s => s.IsCompatible(name)); if (schema == null) { throw new InvalidOperationException($"No modloader installation schema compatible with modloader with name '{name}' for minecraft instance type '{mcInstance.GetType().FullName}' found!"); } schema.Install(mcInstance, name, version); modLoaders.Add(new ModLoaderInfo(name, version)); }
public bool IsCompatible(IMinecraftInstance instance) => instance.GetType() == typeof(T);