public void Install(MmcMinecraftInstance instance, string version)
        {
            instance.PackFile.Load();

            MmcPackFile.Component modloaderComponent = instance.PackFile.Components.FirstOrDefault(
                c => c.Uid == Identificator
                );

            if (modloaderComponent == null)
            {
                InstallModloader(instance, version);
            }
            else
            {
                // Update modloader version
                // modloaderComponent.CachedVersion = version;
                modloaderComponent.Version = version;
            }

            // Create or update version entry in instance.cfg file
            // ReSharper disable once InvertIf
            if (!string.IsNullOrEmpty(VersionConfigProperty))
            {
                MmcConfigFile config = instance.MmcConfig;
                config.GetType().GetProperty(VersionConfigProperty)?.SetValue(config, version);
            }
        }
        protected virtual void UninstallModloader(MmcMinecraftInstance instance)
        {
            MmcPackFile.Component modloaderComponent = instance.PackFile.Components.FirstOrDefault(
                c => c.Uid == Identificator
                );

            if (modloaderComponent == null)
            {
                logger.Error($"Failed to uninstall modloader with id '${Identificator}'. There is no such component in mmc-pack file!");
            }
            else
            {
                instance.PackFile.Components.Remove(modloaderComponent);
            }
        }
Exemplo n.º 3
0
        protected override void UninstallModloader(MmcMinecraftInstance instance)
        {
            // Remove changes from the instance.cfg file
            instance.MmcConfig.McLaunchMethod   = string.Empty;
            instance.MmcConfig.LogPrePostOutput = false;

            // Remove mappings
            MmcPackFile.Component modloaderComponent = instance.PackFile.Components.FirstOrDefault(
                c => c.Uid == "net.fabricmc.intermediary"
                );

            if (modloaderComponent != null)
            {
                instance.PackFile.Components.Remove(modloaderComponent);
            }

            // Remove fabric loader component
            base.UninstallModloader(instance);
        }