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