From 821bcab17a366adc3d605af4e079b953de3caf6e Mon Sep 17 00:00:00 2001 From: meli <57847713+ff-meli@users.noreply.github.com> Date: Wed, 4 Mar 2020 14:39:38 -0800 Subject: [PATCH] actually fix devPlugins... --- Dalamud/Plugin/PluginManager.cs | 40 ++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/Dalamud/Plugin/PluginManager.cs b/Dalamud/Plugin/PluginManager.cs index 9f4ed9750..7e4182849 100644 --- a/Dalamud/Plugin/PluginManager.cs +++ b/Dalamud/Plugin/PluginManager.cs @@ -101,24 +101,23 @@ namespace Dalamud.Plugin var defJsonFile = new FileInfo(Path.Combine(dllFile.Directory.FullName, $"{Path.GetFileNameWithoutExtension(dllFile.Name)}.json")); PluginDefinition pluginDef = null; + // load the definition if it exists, even for raw/developer plugins if (defJsonFile.Exists) { - if (!raw) + Log.Information("Loading definition for plugin DLL {0}", dllFile.FullName); + + pluginDef = + JsonConvert.DeserializeObject( + File.ReadAllText(defJsonFile.FullName)); + + if (pluginDef.ApplicableVersion != this.dalamud.StartInfo.GameVersion && pluginDef.ApplicableVersion != "any") { - Log.Information("Loading definition for plugin DLL {0}", dllFile.FullName); - - pluginDef = - JsonConvert.DeserializeObject( - File.ReadAllText(defJsonFile.FullName)); - - if (pluginDef.ApplicableVersion != this.dalamud.StartInfo.GameVersion && pluginDef.ApplicableVersion != "any") - { - Log.Information("Plugin {0} has not applicable version.", dllFile.FullName); - return false; - } + Log.Information("Plugin {0} has not applicable version.", dllFile.FullName); + return false; } } - else + // but developer plugins don't require one to load + else if (!raw) { Log.Information("Plugin DLL {0} has no definition.", dllFile.FullName); return false; @@ -126,6 +125,21 @@ namespace Dalamud.Plugin var plugin = (IDalamudPlugin)Activator.CreateInstance(type); + // this happens for raw plugins that don't specify a PluginDefinition - just generate a dummy one to avoid crashes anywhere + if (pluginDef == null) + { + pluginDef = new PluginDefinition + { + Author = "developer", + Name = plugin.Name, + InternalName = "devPlugin_" + plugin.Name, + AssemblyVersion = plugin.GetType().Assembly.GetName().Version.ToString(), + Description = "", + ApplicableVersion = "any", + IsHide = false + }; + } + var dalamudInterface = new DalamudPluginInterface(this.dalamud, type.Assembly.GetName().Name, this.pluginConfigs); plugin.Initialize(dalamudInterface); Log.Information("Loaded plugin: {0}", plugin.Name);