Browse Source

Removed all backwards compatability

For some reason it only works with a debugger attached...
4.0.0-beta
Anairkoen Schno 5 years ago
parent
commit
c57e6c8a57
9 changed files with 22 additions and 65 deletions
  1. +0
    -2
      IPA.Loader/IPA.Loader.csproj
  2. +1
    -10
      IPA.Loader/Loader/Composite/CompositeBSPlugin.cs
  3. +0
    -3
      IPA.Loader/Loader/PluginComponent.cs
  4. +10
    -9
      IPA.Loader/Loader/PluginLoader.cs
  5. +8
    -2
      IPA.Loader/Loader/PluginManager.cs
  6. +0
    -20
      IPA.Loader/PluginInterfaces/BeatSaber/IBeatSaberPlugin.cs
  7. +1
    -1
      IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs
  8. +0
    -12
      IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedBeatSaberPlugin.cs
  9. +2
    -6
      IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs

+ 0
- 2
IPA.Loader/IPA.Loader.csproj View File

@ -108,9 +108,7 @@
<Compile Include="Logging\Printers\ColorlessConsolePrinter.cs" /> <Compile Include="Logging\Printers\ColorlessConsolePrinter.cs" />
<Compile Include="Logging\Printers\PluginSubLogPrinter.cs" /> <Compile Include="Logging\Printers\PluginSubLogPrinter.cs" />
<Compile Include="Logging\StdoutInterceptor.cs" /> <Compile Include="Logging\StdoutInterceptor.cs" />
<Compile Include="PluginInterfaces\BeatSaber\IBeatSaberPlugin.cs" />
<Compile Include="PluginInterfaces\BeatSaber\IDisablablePlugin.cs" /> <Compile Include="PluginInterfaces\BeatSaber\IDisablablePlugin.cs" />
<Compile Include="PluginInterfaces\BeatSaber\IEnhancedBeatSaberPlugin.cs" />
<Compile Include="PluginInterfaces\BeatSaber\IEnhancedPlugin.cs" /> <Compile Include="PluginInterfaces\BeatSaber\IEnhancedPlugin.cs" />
<Compile Include="PluginInterfaces\BeatSaber\IPlugin.cs" /> <Compile Include="PluginInterfaces\BeatSaber\IPlugin.cs" />
<Compile Include="PluginInterfaces\IGenericEnhancedPlugin.cs" /> <Compile Include="PluginInterfaces\IGenericEnhancedPlugin.cs" />


+ 1
- 10
IPA.Loader/Loader/Composite/CompositeBSPlugin.cs View File

@ -5,11 +5,7 @@ using Logger = IPA.Logging.Logger;
namespace IPA.Loader.Composite namespace IPA.Loader.Composite
{ {
internal class CompositeBSPlugin :
#pragma warning disable CS0618 // Type or member is obsolete
IBeatSaberPlugin,
#pragma warning restore CS0618 // Type or member is obsolete
_IPlugin
internal class CompositeBSPlugin
{ {
private readonly IEnumerable<PluginLoader.PluginInfo> plugins; private readonly IEnumerable<PluginLoader.PluginInfo> plugins;
@ -19,11 +15,6 @@ namespace IPA.Loader.Composite
this.plugins = plugins; this.plugins = plugins;
} }
[Obsolete]
public void OnApplicationStart() {
Invoke(plugin => (plugin.Plugin as IBeatSaberPlugin)?.OnApplicationStart());
}
public void OnApplicationQuit() { public void OnApplicationQuit() {
Invoke(plugin => plugin.Plugin.OnApplicationQuit()); Invoke(plugin => plugin.Plugin.OnApplicationQuit());
} }


+ 0
- 3
IPA.Loader/Loader/PluginComponent.cs View File

@ -34,9 +34,6 @@ namespace IPA.Loader
gameObject.AddComponent<Updating.BeatMods.Updater>(); gameObject.AddComponent<Updating.BeatMods.Updater>();
#endif #endif
#pragma warning disable CS0612 // Type or member is obsolete
bsPlugins.OnApplicationStart();
#pragma warning restore CS0612 // Type or member is obsolete
ipaPlugins.OnApplicationStart(); ipaPlugins.OnApplicationStart();
SceneManager.activeSceneChanged += OnActiveSceneChanged; SceneManager.activeSceneChanged += OnActiveSceneChanged;


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

@ -124,7 +124,7 @@ namespace IPA.Loader
/// </summary> /// </summary>
public class PluginInfo public class PluginInfo
{ {
internal _IPlugin Plugin { get; set; }
internal IPlugin Plugin { get; set; }
/// <summary> /// <summary>
/// Metadata for the plugin. /// Metadata for the plugin.
@ -196,14 +196,14 @@ namespace IPA.Loader
foreach (var plugin in plugins) foreach (var plugin in plugins)
{ {
try
var metadata = new PluginMetadata
{ {
var metadata = new PluginMetadata
{
File = new FileInfo(Path.Combine(BeatSaber.PluginsPath, plugin)),
IsSelf = false
};
File = new FileInfo(Path.Combine(BeatSaber.PluginsPath, plugin)),
IsSelf = false
};
try
{
var pluginModule = AssemblyDefinition.ReadAssembly(plugin, new ReaderParameters var pluginModule = AssemblyDefinition.ReadAssembly(plugin, new ReaderParameters
{ {
ReadingMode = ReadingMode.Immediate, ReadingMode = ReadingMode.Immediate,
@ -244,7 +244,7 @@ namespace IPA.Loader
if (type.Namespace != pluginNs) continue; if (type.Namespace != pluginNs) continue;
// TODO: change this to just IPlugin // TODO: change this to just IPlugin
if (type.HasInterface(typeof(_IPlugin).FullName))
if (type.HasInterface(typeof(IPlugin).FullName))
{ {
metadata.PluginType = type; metadata.PluginType = type;
break; break;
@ -264,6 +264,7 @@ namespace IPA.Loader
{ {
Logger.loader.Error($"Could not load data for plugin {Path.GetFileName(plugin)}"); Logger.loader.Error($"Could not load data for plugin {Path.GetFileName(plugin)}");
Logger.loader.Error(e); Logger.loader.Error(e);
ignoredPlugins.Add(metadata);
} }
} }
@ -642,7 +643,7 @@ namespace IPA.Loader
} }
var type = meta.Assembly.GetType(meta.PluginType.FullName); var type = meta.Assembly.GetType(meta.PluginType.FullName);
var instance = Activator.CreateInstance(type) as _IPlugin;
var instance = Activator.CreateInstance(type) as IPlugin;
info.Metadata = meta; info.Metadata = meta;
info.Plugin = instance; info.Plugin = instance;


+ 8
- 2
IPA.Loader/Loader/PluginManager.cs View File

@ -32,7 +32,7 @@ namespace IPA.Loader
/// <summary> /// <summary>
/// An <see cref="IEnumerable"/> of new Beat Saber plugins /// An <see cref="IEnumerable"/> of new Beat Saber plugins
/// </summary> /// </summary>
internal static IEnumerable<_IPlugin> BSPlugins => (_bsPlugins ?? throw new InvalidOperationException()).Select(p => p.Plugin);
internal static IEnumerable<IPlugin> BSPlugins => (_bsPlugins ?? throw new InvalidOperationException()).Select(p => p.Plugin);
private static List<PluginInfo> _bsPlugins; private static List<PluginInfo> _bsPlugins;
internal static IEnumerable<PluginInfo> BSMetas => _bsPlugins; internal static IEnumerable<PluginInfo> BSMetas => _bsPlugins;
@ -324,11 +324,17 @@ namespace IPA.Loader
// initialize BSIPA plugins first // initialize BSIPA plugins first
_bsPlugins.AddRange(PluginLoader.LoadPlugins()); _bsPlugins.AddRange(PluginLoader.LoadPlugins());
var metadataPaths = PluginsMetadata.Select(m => m.File.FullName).ToList();
var ignoredPaths = ignoredPlugins.Select(m => m.File.FullName).ToList();
var disabledPaths = DisabledPlugins.Select(m => m.File.FullName).ToList();
//Copy plugins to .cache //Copy plugins to .cache
string[] originalPlugins = Directory.GetFiles(pluginDirectory, "*.dll"); string[] originalPlugins = Directory.GetFiles(pluginDirectory, "*.dll");
foreach (string s in originalPlugins) foreach (string s in originalPlugins)
{ {
if (PluginsMetadata.Select(m => m.File.FullName).Contains(s)) continue;
if (metadataPaths.Contains(s)) continue;
if (ignoredPaths.Contains(s)) continue;
if (disabledPaths.Contains(s)) continue;
string pluginCopy = Path.Combine(cacheDir, Path.GetFileName(s)); string pluginCopy = Path.Combine(cacheDir, Path.GetFileName(s));
#region Fix assemblies for refactor #region Fix assemblies for refactor


+ 0
- 20
IPA.Loader/PluginInterfaces/BeatSaber/IBeatSaberPlugin.cs View File

@ -1,20 +0,0 @@
using System;
// ReSharper disable CheckNamespace
namespace IPA
{
/// <summary>
/// Interface for Beat Saber plugins. Every class that implements this will be loaded if the DLL is placed at
/// data/Managed/Plugins.
/// </summary>
[Obsolete("Use IPA.IPlugin instead")]
public interface IBeatSaberPlugin : _IPlugin
{
/// <summary>
/// Gets invoked when the application is started.
///
/// THIS EVENT WILL NOT BE GUARANTEED TO FIRE. USE Init OR <see cref="IPlugin.OnEnable"/> INSTEAD.
/// </summary>
void OnApplicationStart();
}
}

+ 1
- 1
IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs View File

@ -21,7 +21,7 @@
/// from events. After this is called there should be no lingering effects of the mod. /// from events. After this is called there should be no lingering effects of the mod.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This will get called at shutdown, after <see cref="_IPlugin.OnApplicationQuit"/>, as well as when the
/// This will get called at shutdown, after <see cref="IPlugin.OnApplicationQuit"/>, as well as when the
/// plugin is disabled at runtime. /// plugin is disabled at runtime.
/// </remarks> /// </remarks>
void OnDisable(); void OnDisable();


+ 0
- 12
IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedBeatSaberPlugin.cs View File

@ -1,12 +0,0 @@
// ReSharper disable CheckNamespace
namespace IPA
{
/// <inheritdoc cref="IBeatSaberPlugin" />
/// <summary>
/// An enhanced version of a standard BeatSaber plugin.
/// </summary>
[System.Obsolete]
public interface IEnhancedBeatSaberPlugin : IBeatSaberPlugin, IGenericEnhancedPlugin
{
}
}

+ 2
- 6
IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs View File

@ -6,7 +6,7 @@ namespace IPA
/// Interface for BSIPA plugins. Every class that implements this will be loaded if the DLL is placed at /// Interface for BSIPA plugins. Every class that implements this will be loaded if the DLL is placed at
/// &lt;install dir&gt;/Plugins. /// &lt;install dir&gt;/Plugins.
/// </summary> /// </summary>
public interface IPlugin : _IPlugin
public interface IPlugin
{ {
/// <summary> /// <summary>
/// Called when a plugin is enabled. This is where you should set up Harmony patches and the like. /// Called when a plugin is enabled. This is where you should set up Harmony patches and the like.
@ -18,11 +18,7 @@ namespace IPA
/// Init will only ever be called once. /// Init will only ever be called once.
/// </remarks> /// </remarks>
void OnEnable(); void OnEnable();
}
/// <summary>
/// An interface for providing compatability with BSIPA 3.x.x. Do not use.
/// </summary>
public interface _IPlugin {
/// <summary> /// <summary>
/// Gets invoked when the application is closed. /// Gets invoked when the application is closed.
/// </summary> /// </summary>


Loading…
Cancel
Save