Beispiel #1
0
        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)}");
        }
Beispiel #2
0
 public override bool IsCompatible(IMinecraftInstance instance)
 {
     return(instance.GetType() == typeof(TInstance));
 }
Beispiel #3
0
        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);