Browse Source

Moved DefineFeature main execution to BeforeInit

pull/53/head
Anairkoen Schno 3 years ago
parent
commit
ee13166561
Signed by: DaNike GPG Key ID: BEFB74D5F3FC4387
4 changed files with 13 additions and 13 deletions
  1. +1
    -1
      IPA.Loader/Loader/Features/ConfigProviderFeature.cs
  2. +2
    -2
      IPA.Loader/Loader/Features/DefineFeature.cs
  3. +1
    -1
      IPA.Loader/Loader/Features/Feature.cs
  4. +9
    -9
      IPA.Loader/Loader/PluginLoader.cs

+ 1
- 1
IPA.Loader/Loader/Features/ConfigProviderFeature.cs View File

@ -10,7 +10,7 @@ namespace IPA.Loader.Features
private class DataModel
{
[JsonProperty("type", Required = Required.Always)]
public string TypeName;
public string TypeName = "";
}
protected override bool Initialize(PluginMetadata meta, JObject featureData)


+ 2
- 2
IPA.Loader/Loader/Features/DefineFeature.cs View File

@ -13,7 +13,7 @@ namespace IPA.Loader.Features
private class DataModel
{
[JsonProperty("type", Required = Required.Always)]
public string TypeName;
public string TypeName = "";
[JsonProperty("name", Required = Required.DisallowNull)]
public string ActualName = null;
@ -40,7 +40,7 @@ namespace IPA.Loader.Features
return PreregisterFeature(meta, data.Name);
}
public override void AfterInit(PluginMetadata meta, object pluginInstance)
public override void BeforeInit(PluginMetadata meta)
{
Logger.features.Debug("Executing DefineFeature AfterInit");


+ 1
- 1
IPA.Loader/Loader/Features/Feature.cs View File

@ -42,7 +42,7 @@ namespace IPA.Loader.Features
/// </summary>
/// <param name="plugin">the plugin to be initialized</param>
/// <returns>whether or not to call the Init method</returns>
public virtual bool BeforeInit(PluginMetadata plugin) => true;
public virtual void BeforeInit(PluginMetadata plugin) { }
/// <summary>
/// Called after a plugin has been fully initialized, whether or not there is an `Init` method. This should never throw an exception.


+ 9
- 9
IPA.Loader/Loader/PluginLoader.cs View File

@ -812,15 +812,14 @@ namespace IPA.Loader
foreach (var feature in meta.Features)
{
if (!feature.BeforeInit(meta))
try
{
Logger.loader.Warn(
$"Feature {feature?.FeatureName} denied plugin {meta.Name} from initializing! {feature?.InvalidMessage}");
ignoredPlugins.Add(meta, new IgnoreReason(Reason.Feature)
{
ReasonText = $"Denied in {nameof(Feature.BeforeInit)} of feature {feature?.FeatureName}:\n\t{feature?.InvalidMessage}"
});
return null;
feature.BeforeInit(meta);
}
catch (Exception e)
{
Logger.loader.Critical($"Feature errored in {nameof(Feature.BeforeInit)}:");
Logger.loader.Critical(e);
}
}
@ -862,7 +861,8 @@ namespace IPA.Loader
}
catch (Exception e)
{
Logger.loader.Critical($"Feature errored in {nameof(Feature.AfterInit)}: {e}");
Logger.loader.Critical($"Feature errored in {nameof(Feature.AfterInit)}:");
Logger.loader.Critical(e);
}
return exec;


Loading…
Cancel
Save