actually fix devPlugins...

This commit is contained in:
meli 2020-03-04 14:39:38 -08:00
parent 1e3b39b8d9
commit 821bcab17a

View file

@ -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<PluginDefinition>(
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<PluginDefinition>(
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);