diff --git a/Dalamud/Plugin/Internal/Profiles/ProfileManager.cs b/Dalamud/Plugin/Internal/Profiles/ProfileManager.cs index f189424a3..b7073ac99 100644 --- a/Dalamud/Plugin/Internal/Profiles/ProfileManager.cs +++ b/Dalamud/Plugin/Internal/Profiles/ProfileManager.cs @@ -268,21 +268,9 @@ internal class ProfileManager : IServiceType private void LoadProfilesFromConfigInitially() { - var needMigration = false; - if (this.config.DefaultProfile == null) - { - this.config.DefaultProfile = new ProfileModelV1(); - needMigration = true; - } - + this.config.DefaultProfile ??= new ProfileModelV1(); this.profiles.Add(new Profile(this, this.config.DefaultProfile, true, true)); - if (needMigration) - { - // Don't think we need this here with the migration logic in GetWantState - //this.MigratePluginsIntoDefaultProfile(); - } - this.config.SavedProfiles ??= new List(); foreach (var profileModel in this.config.SavedProfiles) { @@ -291,72 +279,4 @@ internal class ProfileManager : IServiceType this.config.QueueSave(); } - - // This duplicates some of the original handling in PM; don't care though - /* - private void MigratePluginsIntoDefaultProfile() - { - var pluginDirectory = new DirectoryInfo(Service.Get().PluginDirectory!); - var pluginDefs = new List(); - - Log.Information($"Now migrating plugins at {pluginDirectory} into profiles"); - - // Nothing to migrate - if (!pluginDirectory.Exists) - { - Log.Information("\t=> Plugin directory didn't exist, nothing to migrate"); - return; - } - - // Add installed plugins. These are expected to be in a specific format so we can look for exactly that. - foreach (var pluginDir in pluginDirectory.GetDirectories()) - { - var versionsDefs = new List(); - foreach (var versionDir in pluginDir.GetDirectories()) - { - try - { - var dllFile = new FileInfo(Path.Combine(versionDir.FullName, $"{pluginDir.Name}.dll")); - var manifestFile = LocalPluginManifest.GetManifestFile(dllFile); - - if (!manifestFile.Exists) - continue; - - var manifest = LocalPluginManifest.Load(manifestFile); - versionsDefs.Add(new PluginDef(dllFile, manifest, false)); - } - catch (Exception ex) - { - Log.Error(ex, "Could not load manifest for installed at {Directory}", versionDir.FullName); - } - } - - try - { - pluginDefs.Add(versionsDefs.MaxBy(x => x.Manifest!.EffectiveVersion)); - } - catch (Exception ex) - { - Log.Error(ex, "Couldn't choose best version for plugin: {Name}", pluginDir.Name); - } - } - - var defaultProfile = this.DefaultProfile; - foreach (var pluginDef in pluginDefs) - { - if (pluginDef.Manifest == null) - { - Log.Information($"\t=> Skipping DLL at {pluginDef.DllFile.FullName}, no valid manifest"); - continue; - } - - // OK for migration code -#pragma warning disable CS0618 - defaultProfile.AddOrUpdate(pluginDef.Manifest.InternalName, !pluginDef.Manifest.Disabled, false); - Log.Information( - $"\t=> Added {pluginDef.Manifest.InternalName} to default profile with {!pluginDef.Manifest.Disabled}"); -#pragma warning restore CS0618 - } - } - */ } diff --git a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs index db5556662..2ef0269a3 100644 --- a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs @@ -200,14 +200,6 @@ internal class LocalPlugin : IDisposable /// public bool IsLoaded => this.State == PluginState.Loaded; - /* - /// - /// Gets a value indicating whether the plugin is disabled. - /// - [Obsolete("This is no longer accurate, use the profile manager instead.", true)] - public bool IsDisabled => this.Manifest.Disabled; - */ - /// /// Gets a value indicating whether this plugin is wanted active by any profile. /// INCLUDES the default profile. @@ -349,7 +341,7 @@ internal class LocalPlugin : IDisposable if (this.Manifest.DalamudApiLevel < PluginManager.DalamudApiLevel && !pluginManager.LoadAllApiLevels) throw new InvalidPluginOperationException($"Unable to load {this.Name}, incompatible API level"); - // TODO: should we throw here? + // We might want to throw here? if (!this.IsWantedByAnyProfile) Log.Warning("{Name} is loading, but isn't wanted by any profile", this.Name); @@ -568,43 +560,6 @@ internal class LocalPlugin : IDisposable await this.LoadAsync(PluginLoadReason.Reload, true); } - /* - /// - /// Revert a disable. Must be unloaded first, does not load. - /// - [Obsolete("Profile API", true)] - public void Enable() - { - // Allowed: Unloaded, UnloadError - switch (this.State) - { - case PluginState.Loading: - case PluginState.Unloading: - case PluginState.Loaded: - case PluginState.LoadError: - throw new InvalidPluginOperationException($"Unable to enable {this.Name}, still loaded"); - case PluginState.Unloaded: - break; - case PluginState.UnloadError: - break; - case PluginState.DependencyResolutionFailed: - throw new InvalidPluginOperationException($"Unable to enable {this.Name}, dependency resolution failed"); - default: - throw new ArgumentOutOfRangeException(this.State.ToString()); - } - - // NOTE(goat): This is inconsequential, and we do have situations where a plugin can end up enabled but not loaded: - // Orphaned plugins can have their repo added back, but may not have been loaded at boot and may still be enabled. - // We don't want to disable orphaned plugins when they are orphaned so this is how it's going to be. - // if (!this.Manifest.Disabled) - // throw new InvalidPluginOperationException($"Unable to enable {this.Name}, not disabled"); - - this.Manifest.Disabled = false; - this.Manifest.ScheduledForDeletion = false; - this.SaveManifest(); - } - */ - /// /// Check if anything forbids this plugin from loading. /// @@ -626,39 +581,6 @@ internal class LocalPlugin : IDisposable return true; } - /* - /// - /// Disable this plugin, must be unloaded first. - /// - [Obsolete("Profile API", true)] - public void Disable() - { - // Allowed: Unloaded, UnloadError - switch (this.State) - { - case PluginState.Loading: - case PluginState.Unloading: - case PluginState.Loaded: - case PluginState.LoadError: - throw new InvalidPluginOperationException($"Unable to disable {this.Name}, still loaded"); - case PluginState.Unloaded: - break; - case PluginState.UnloadError: - break; - case PluginState.DependencyResolutionFailed: - return; // This is a no-op. - default: - throw new ArgumentOutOfRangeException(this.State.ToString()); - } - - if (this.Manifest.Disabled) - throw new InvalidPluginOperationException($"Unable to disable {this.Name}, already disabled"); - - this.Manifest.Disabled = true; - this.SaveManifest(); - } - */ - /// /// Schedule the deletion of this plugin on next cleanup. ///