diff --git a/Il2CppInspector.CLI/PluginOptions.cs b/Il2CppInspector.CLI/PluginOptions.cs index dd6dd83..3a38963 100644 --- a/Il2CppInspector.CLI/PluginOptions.cs +++ b/Il2CppInspector.CLI/PluginOptions.cs @@ -121,13 +121,21 @@ namespace Il2CppInspector.CLI // Get plugin option classes public static Type[] GetPluginOptionTypes() { // Don't do anything if there are no loaded plugins - var plugins = PluginManager.AvailablePlugins; + try { + var plugins = PluginManager.AvailablePlugins; - if (!plugins.Any()) - return Array.Empty(); + if (!plugins.Any()) + return Array.Empty(); - // Create CommandLine-friendly option classes for each plugin - return plugins.Select(p => CreateOptionsFromPlugin(p)).ToArray(); + // Create CommandLine-friendly option classes for each plugin + return plugins.Select(p => CreateOptionsFromPlugin(p)).ToArray(); + } + catch (InvalidOperationException ex) { + Console.Error.WriteLine(ex.Message); + Environment.Exit(1); + + return null; + } } // Parse all options for all plugins diff --git a/Il2CppInspector.Common/Plugins/Internal/PluginManager.cs b/Il2CppInspector.Common/Plugins/Internal/PluginManager.cs index 3d426ba..9656f02 100644 --- a/Il2CppInspector.Common/Plugins/Internal/PluginManager.cs +++ b/Il2CppInspector.Common/Plugins/Internal/PluginManager.cs @@ -174,6 +174,11 @@ namespace Il2CppInspector // Current version if (typeof(IPlugin).IsAssignableFrom(type) && !type.IsAbstract) { var plugin = (IPlugin) Activator.CreateInstance(type); + + // Don't allow multiple identical plugins to load + if (AsInstance.ManagedPlugins.Any(p => p.Plugin.Id == plugin.Id)) + throw new Exception($"Multiple copies of {plugin.Name} were found. Please ensure the plugins folder only contains one copy of each plugin."); + AsInstance.ManagedPlugins.Add(new ManagedPlugin { Plugin = plugin, Available = true, Enabled = false }); } diff --git a/Il2CppInspector.GUI/App.xaml.cs b/Il2CppInspector.GUI/App.xaml.cs index fb6f256..edfcc15 100644 --- a/Il2CppInspector.GUI/App.xaml.cs +++ b/Il2CppInspector.GUI/App.xaml.cs @@ -126,7 +126,12 @@ namespace Il2CppInspectorGUI catch (NotSupportedException) { } // Load plugins if they aren't already - PluginManager.EnsureInit(); + try { + PluginManager.EnsureInit(); + } catch (InvalidOperationException ex) { + MessageBox.Show(ex.Message, "Fatal error loading plugins"); + Environment.Exit(1); + } // Arrange plugins var loadedPlugins = PluginManager.AsInstance.ManagedPlugins;