mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 13:14:17 +01:00
Merge pull request #522 from daemitus/safeMode
This commit is contained in:
commit
2ef5a9706d
4 changed files with 41 additions and 67 deletions
|
|
@ -236,28 +236,24 @@ namespace Dalamud
|
||||||
{
|
{
|
||||||
Log.Information("[T3] START!");
|
Log.Information("[T3] START!");
|
||||||
|
|
||||||
if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_PLUGINS") ?? "false"))
|
var pluginManager = Service<PluginManager>.Set();
|
||||||
|
Service<CallGate>.Set();
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
pluginManager.OnInstalledPluginsChanged += Troubleshooting.LogTroubleshooting;
|
||||||
{
|
|
||||||
Service<CallGate>.Set();
|
|
||||||
|
|
||||||
var pluginManager = Service<PluginManager>.Set();
|
Log.Information("[T3] PM OK!");
|
||||||
pluginManager.OnInstalledPluginsChanged += () =>
|
|
||||||
Troubleshooting.LogTroubleshooting();
|
|
||||||
|
|
||||||
Log.Information("[T3] PM OK!");
|
pluginManager.CleanupPlugins();
|
||||||
|
Log.Information("[T3] PMC OK!");
|
||||||
|
|
||||||
pluginManager.CleanupPlugins();
|
pluginManager.LoadAllPlugins();
|
||||||
Log.Information("[T3] PMC OK!");
|
Log.Information("[T3] PML OK!");
|
||||||
|
}
|
||||||
pluginManager.LoadAllPlugins();
|
catch (Exception ex)
|
||||||
Log.Information("[T3] PML OK!");
|
{
|
||||||
}
|
Log.Error(ex, "Plugin load failed.");
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Error(ex, "Plugin load failed.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Service<DalamudInterface>.Set();
|
Service<DalamudInterface>.Set();
|
||||||
|
|
|
||||||
|
|
@ -770,6 +770,12 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
{
|
{
|
||||||
var pluginManager = Service<PluginManager>.Get();
|
var pluginManager = Service<PluginManager>.Get();
|
||||||
|
|
||||||
|
if (pluginManager.SafeMode)
|
||||||
|
{
|
||||||
|
ImGui.Text(Locs.TabBody_SafeMode);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var ready = pluginManager.PluginsReady && pluginManager.ReposReady;
|
var ready = pluginManager.PluginsReady && pluginManager.ReposReady;
|
||||||
|
|
||||||
if (!ready)
|
if (!ready)
|
||||||
|
|
@ -1873,6 +1879,8 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
|
|
||||||
public static string TabBody_DownloadFailed => Loc.Localize("InstallerDownloadFailed", "Download failed.");
|
public static string TabBody_DownloadFailed => Loc.Localize("InstallerDownloadFailed", "Download failed.");
|
||||||
|
|
||||||
|
public static string TabBody_SafeMode => Loc.Localize("InstallerSafeMode", "Dalamud is running in Plugin Safe Mode, restart to activate plugins.");
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Search text
|
#region Search text
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ using Dalamud.Plugin.Internal.Exceptions;
|
||||||
using Dalamud.Plugin.Internal.Types;
|
using Dalamud.Plugin.Internal.Types;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Dalamud.Plugin.Internal
|
namespace Dalamud.Plugin.Internal
|
||||||
|
|
@ -52,6 +51,7 @@ namespace Dalamud.Plugin.Internal
|
||||||
public PluginManager()
|
public PluginManager()
|
||||||
{
|
{
|
||||||
var startInfo = Service<DalamudStartInfo>.Get();
|
var startInfo = Service<DalamudStartInfo>.Get();
|
||||||
|
var configuration = Service<DalamudConfiguration>.Get();
|
||||||
|
|
||||||
this.pluginDirectory = new DirectoryInfo(startInfo.PluginDirectory);
|
this.pluginDirectory = new DirectoryInfo(startInfo.PluginDirectory);
|
||||||
this.devPluginDirectory = new DirectoryInfo(startInfo.DefaultPluginDirectory);
|
this.devPluginDirectory = new DirectoryInfo(startInfo.DefaultPluginDirectory);
|
||||||
|
|
@ -62,6 +62,13 @@ namespace Dalamud.Plugin.Internal
|
||||||
if (!this.devPluginDirectory.Exists)
|
if (!this.devPluginDirectory.Exists)
|
||||||
this.devPluginDirectory.Create();
|
this.devPluginDirectory.Create();
|
||||||
|
|
||||||
|
var noPlugins = bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_PLUGINS") ?? "false");
|
||||||
|
if (this.SafeMode = noPlugins || configuration.PluginSafeMode)
|
||||||
|
{
|
||||||
|
configuration.PluginSafeMode = false;
|
||||||
|
configuration.Save();
|
||||||
|
}
|
||||||
|
|
||||||
this.PluginConfigs = new PluginConfigurations(Path.Combine(Path.GetDirectoryName(startInfo.ConfigurationPath) ?? string.Empty, "pluginConfigs"));
|
this.PluginConfigs = new PluginConfigurations(Path.Combine(Path.GetDirectoryName(startInfo.ConfigurationPath) ?? string.Empty, "pluginConfigs"));
|
||||||
|
|
||||||
var bannedPluginsJson = File.ReadAllText(Path.Combine(startInfo.AssetDirectory, "UIRes", "bannedplugin.json"));
|
var bannedPluginsJson = File.ReadAllText(Path.Combine(startInfo.AssetDirectory, "UIRes", "bannedplugin.json"));
|
||||||
|
|
@ -113,9 +120,9 @@ namespace Dalamud.Plugin.Internal
|
||||||
public bool ReposReady => this.Repos.All(repo => repo.State != PluginRepositoryState.InProgress);
|
public bool ReposReady => this.Repos.All(repo => repo.State != PluginRepositoryState.InProgress);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of all IPC subscriptions.
|
/// Gets a value indicating whether the plugin manager started in safe mode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<IpcSubscription> IpcSubscriptions { get; } = new();
|
public bool SafeMode { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="PluginConfigurations"/> object used when initializing plugins.
|
/// Gets the <see cref="PluginConfigurations"/> object used when initializing plugins.
|
||||||
|
|
@ -163,18 +170,14 @@ namespace Dalamud.Plugin.Internal
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void LoadAllPlugins()
|
public void LoadAllPlugins()
|
||||||
{
|
{
|
||||||
var configuration = Service<DalamudConfiguration>.Get();
|
if (this.SafeMode)
|
||||||
|
|
||||||
if (configuration.PluginSafeMode)
|
|
||||||
{
|
{
|
||||||
Log.Information("PluginSafeMode was enabled, not loading any plugins.");
|
Log.Information("PluginSafeMode was enabled, not loading any plugins.");
|
||||||
|
|
||||||
configuration.PluginSafeMode = false;
|
|
||||||
configuration.Save();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var configuration = Service<DalamudConfiguration>.Get();
|
||||||
|
|
||||||
var pluginDefs = new List<PluginDef>();
|
var pluginDefs = new List<PluginDef>();
|
||||||
var devPluginDefs = new List<PluginDef>();
|
var devPluginDefs = new List<PluginDef>();
|
||||||
|
|
||||||
|
|
@ -326,6 +329,12 @@ namespace Dalamud.Plugin.Internal
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ScanDevPlugins()
|
public void ScanDevPlugins()
|
||||||
{
|
{
|
||||||
|
if (this.SafeMode)
|
||||||
|
{
|
||||||
|
Log.Information("PluginSafeMode was enabled, not scanning any dev plugins.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var configuration = Service<DalamudConfiguration>.Get();
|
var configuration = Service<DalamudConfiguration>.Get();
|
||||||
|
|
||||||
if (!this.devPluginDirectory.Exists)
|
if (!this.devPluginDirectory.Exists)
|
||||||
|
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Dynamic;
|
|
||||||
|
|
||||||
namespace Dalamud.Plugin.Internal.Types
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// This class represents an IPC subscription between two plugins.
|
|
||||||
/// </summary>
|
|
||||||
internal record IpcSubscription
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="IpcSubscription"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sourcePluginName">The source plugin name.</param>
|
|
||||||
/// <param name="subPluginName">The name of the plugin being subscribed to.</param>
|
|
||||||
/// <param name="subAction">The subscription action.</param>
|
|
||||||
public IpcSubscription(string sourcePluginName, string subPluginName, Action<ExpandoObject> subAction)
|
|
||||||
{
|
|
||||||
this.SourcePluginName = sourcePluginName;
|
|
||||||
this.SubPluginName = subPluginName;
|
|
||||||
this.SubAction = subAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the name of the plugin requesting the subscription.
|
|
||||||
/// </summary>
|
|
||||||
public string SourcePluginName { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the name of the plugin being subscribed to.
|
|
||||||
/// </summary>
|
|
||||||
public string SubPluginName { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the subscription action.
|
|
||||||
/// </summary>
|
|
||||||
public Action<ExpandoObject> SubAction { get; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue