From 3b4b69eb05c225459f4aba5bdb813db25f50d9cf Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sun, 11 Aug 2019 19:04:12 -0500 Subject: [PATCH] Loader now checks for manifest before plugin class --- IPA.Loader/Loader/PluginLoader.cs | 61 ++++++++++++++------------- Refs/Assembly-CSharp.dll | Bin 637440 -> 637440 bytes Refs/Unity.TextMeshPro.dll | Bin 84480 -> 84480 bytes Refs/UnityEngine.CoreModule.Net4.dll | Bin 613888 -> 613888 bytes 4 files changed, 31 insertions(+), 30 deletions(-) diff --git a/IPA.Loader/Loader/PluginLoader.cs b/IPA.Loader/Loader/PluginLoader.cs index c493b842..f2f51735 100644 --- a/IPA.Loader/Loader/PluginLoader.cs +++ b/IPA.Loader/Loader/PluginLoader.cs @@ -184,38 +184,15 @@ namespace IPA.Loader AssemblyResolver = new CecilLibLoader() }).MainModule; - foreach (var type in pluginModule.Types) - { - foreach (var inter in type.Interfaces) - { - var ifType = inter.InterfaceType; - - if (typeof(IBeatSaberPlugin).FullName == ifType.FullName) - { - metadata.PluginType = type; - break; - } - } - - if (metadata.PluginType != null) break; - } - - if (metadata.PluginType == null) - { - Logger.loader.Notice( - #if DIRE_LOADER_WARNINGS - $"Could not find plugin type for {Path.GetFileName(plugin)}" - #else - $"New plugin type not present in {Path.GetFileName(plugin)}; maybe an old plugin?" - #endif - ); - continue; - } + string pluginNs = ""; foreach (var resource in pluginModule.Resources) { + const string manifestSuffix = ".manifest.json"; if (!(resource is EmbeddedResource embedded) || - embedded.Name != $"{metadata.PluginType.Namespace}.manifest.json") continue; + !embedded.Name.EndsWith(manifestSuffix)) continue; + + pluginNs = embedded.Name.Substring(0, embedded.Name.Length - manifestSuffix.Length); string manifest; using (var manifestReader = new StreamReader(embedded.GetResourceStream())) @@ -227,8 +204,32 @@ namespace IPA.Loader if (metadata.Manifest == null) { - Logger.loader.Error("Could not find manifest.json in namespace " + - $"{metadata.PluginType.Namespace} for {Path.GetFileName(plugin)}"); +#if DIRE_LOADER_WARNINGS + Logger.loader.Error($"Could not find manifest.json for {Path.GetFileName(plugin)}"); +#else + Logger.loader.Notice($"No manifest.json in {Path.GetFileName(plugin)}"); +#endif + continue; + } + + foreach (var type in pluginModule.Types) + { + if (type.Namespace != pluginNs) continue; + + foreach (var inter in type.Interfaces) + { + if (typeof(IBeatSaberPlugin).FullName == inter.InterfaceType.FullName) + { + metadata.PluginType = type; + goto type_loop_done; // break out of both loops + } + } + } + + type_loop_done: + if (metadata.PluginType == null) + { + Logger.loader.Error($"No plugin found in the manifest namespace ({pluginNs}) in {Path.GetFileName(plugin)}"); continue; } diff --git a/Refs/Assembly-CSharp.dll b/Refs/Assembly-CSharp.dll index f7299b9c85c6e0678b808185f234b1a48148d814..311527b0888d5437d34363a17e5e8a49584af54f 100644 GIT binary patch delta 74 zcmZqpqSo+5Z9)gL$OVhW?$&O`)^4WOZsyi*maW~aoo^T=+eP290x=s9vu_uD%kiIC cV4;#t+1VrWy*pm1mCaxEz;3(BM~*uu0GYrb^8f$< delta 74 zcmZqpqSo+5Z9)h0?87pR-L2h>t=&wm-OR1sEL*!-JKr!$w2QuF1!6WJX5TLQmg7IO c0E6h7y}vADoja2iR_-km__BgdT+0G~e~EdT%j diff --git a/Refs/Unity.TextMeshPro.dll b/Refs/Unity.TextMeshPro.dll index a37e311ac055c56b2df0f179490f9471260ec338..5b4e9492f6607a391f21f6c015041c79e416aab4 100644 GIT binary patch delta 42 ycmZpe!rCx}bwUTT;024u?ycR7wrT<=`Z=!sf12dFr8{!U5i3dG?KjjIHIxB(%@KG2 delta 42 ycmZpe!rCx}bwUU8;s5{u