You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

712 lines
27 KiB

  1. using IPA.Config;
  2. using IPA.Loader.Features;
  3. using IPA.Logging;
  4. using IPA.Utilities;
  5. using Mono.Cecil;
  6. using Newtonsoft.Json;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Reflection;
  12. using System.Text.RegularExpressions;
  13. using System.Threading.Tasks;
  14. using Version = SemVer.Version;
  15. #if NET3
  16. using Net3_Proxy;
  17. using Path = Net3_Proxy.Path;
  18. using File = Net3_Proxy.File;
  19. using Directory = Net3_Proxy.Directory;
  20. #endif
  21. namespace IPA.Loader
  22. {
  23. /// <summary>
  24. /// A type to manage the loading of plugins.
  25. /// </summary>
  26. public class PluginLoader
  27. {
  28. internal static Task LoadTask() => Task.Factory.StartNew(() =>
  29. {
  30. YeetIfNeeded();
  31. LoadMetadata();
  32. Resolve();
  33. ComputeLoadOrder();
  34. FilterDisabled();
  35. ResolveDependencies();
  36. });
  37. /// <summary>
  38. /// A class which describes a loaded plugin.
  39. /// </summary>
  40. public class PluginMetadata
  41. {
  42. /// <summary>
  43. /// The assembly the plugin was loaded from.
  44. /// </summary>
  45. /// <value>the loaded Assembly that contains the plugin main type</value>
  46. public Assembly Assembly { get; internal set; }
  47. /// <summary>
  48. /// The TypeDefinition for the main type of the plugin.
  49. /// </summary>
  50. /// <value>the Cecil definition for the plugin main type</value>
  51. public TypeDefinition PluginType { get; internal set; }
  52. /// <summary>
  53. /// The human readable name of the plugin.
  54. /// </summary>
  55. /// <value>the name of the plugin</value>
  56. public string Name { get; internal set; }
  57. /// <summary>
  58. /// The BeatMods ID of the plugin, or null if it doesn't have one.
  59. /// </summary>
  60. /// <value>the updater ID of the plugin</value>
  61. public string Id { get; internal set; }
  62. /// <summary>
  63. /// The version of the plugin.
  64. /// </summary>
  65. /// <value>the version of the plugin</value>
  66. public Version Version { get; internal set; }
  67. /// <summary>
  68. /// The file the plugin was loaded from.
  69. /// </summary>
  70. /// <value>the file the plugin was loaded from</value>
  71. public FileInfo File { get; internal set; }
  72. // ReSharper disable once UnusedAutoPropertyAccessor.Global
  73. /// <summary>
  74. /// The features this plugin requests.
  75. /// </summary>
  76. /// <value>the list of features requested by the plugin</value>
  77. public IReadOnlyList<Feature> Features => InternalFeatures;
  78. internal readonly List<Feature> InternalFeatures = new List<Feature>();
  79. internal bool IsSelf;
  80. /// <summary>
  81. /// Whether or not this metadata object represents a bare manifest.
  82. /// </summary>
  83. /// <value><see langword="true"/> if it is bare, <see langword="false"/> otherwise</value>
  84. public bool IsBare { get; internal set; }
  85. private PluginManifest manifest;
  86. internal HashSet<PluginMetadata> Dependencies { get; } = new HashSet<PluginMetadata>();
  87. internal PluginManifest Manifest
  88. {
  89. get => manifest;
  90. set
  91. {
  92. manifest = value;
  93. Name = value.Name;
  94. Version = value.Version;
  95. Id = value.Id;
  96. }
  97. }
  98. /// <summary>
  99. /// Gets all of the metadata as a readable string.
  100. /// </summary>
  101. /// <returns>the readable printable metadata string</returns>
  102. public override string ToString() => $"{Name}({Id}@{Version})({PluginType?.FullName}) from '{Utils.GetRelativePath(File?.FullName, BeatSaber.InstallPath)}'";
  103. }
  104. /// <summary>
  105. /// A container object for all the data relating to a plugin.
  106. /// </summary>
  107. public class PluginInfo
  108. {
  109. internal IBeatSaberPlugin Plugin { get; set; }
  110. /// <summary>
  111. /// Metadata for the plugin.
  112. /// </summary>
  113. /// <value>the metadata for this plugin</value>
  114. public PluginMetadata Metadata { get; internal set; } = new PluginMetadata();
  115. }
  116. internal static void YeetIfNeeded()
  117. {
  118. string pluginDir = BeatSaber.PluginsPath;
  119. var gameVer = BeatSaber.GameVersion;
  120. var lastVerS = SelfConfig.LastGameVersion_;
  121. var lastVer = lastVerS != null ? new AlmostVersion(lastVerS, gameVer) : null;
  122. if (SelfConfig.YeetMods_ && lastVer != null && gameVer != lastVer)
  123. {
  124. var oldPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {lastVer} Plugins");
  125. var newPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {gameVer} Plugins");
  126. if (Directory.Exists(oldPluginsName))
  127. Directory.Delete(oldPluginsName, true);
  128. Directory.Move(pluginDir, oldPluginsName);
  129. if (Directory.Exists(newPluginsName))
  130. Directory.Move(newPluginsName, pluginDir);
  131. else
  132. Directory.CreateDirectory(pluginDir);
  133. }
  134. SelfConfig.SelfConfigRef.Value.LastGameVersion = gameVer.ToString();
  135. SelfConfig.LoaderConfig.Store(SelfConfig.SelfConfigRef.Value);
  136. }
  137. internal static List<PluginMetadata> PluginsMetadata = new List<PluginMetadata>();
  138. internal static List<PluginMetadata> DisabledPlugins = new List<PluginMetadata>();
  139. private static readonly Regex embeddedTextDescriptionPattern = new Regex(@"#!\[(.+)\]", RegexOptions.Compiled | RegexOptions.Singleline);
  140. internal static void LoadMetadata()
  141. {
  142. string[] plugins = Directory.GetFiles(BeatSaber.PluginsPath, "*.dll");
  143. try
  144. {
  145. var selfMeta = new PluginMetadata
  146. {
  147. Assembly = Assembly.GetExecutingAssembly(),
  148. File = new FileInfo(Path.Combine(BeatSaber.InstallPath, "IPA.exe")),
  149. PluginType = null,
  150. IsSelf = true
  151. };
  152. string manifest;
  153. using (var manifestReader =
  154. new StreamReader(
  155. selfMeta.Assembly.GetManifestResourceStream(typeof(PluginLoader), "manifest.json") ??
  156. throw new InvalidOperationException()))
  157. manifest = manifestReader.ReadToEnd();
  158. selfMeta.Manifest = JsonConvert.DeserializeObject<PluginManifest>(manifest);
  159. PluginsMetadata.Add(selfMeta);
  160. }
  161. catch (Exception e)
  162. {
  163. Logger.loader.Critical("Error loading own manifest");
  164. Logger.loader.Critical(e);
  165. }
  166. foreach (var plugin in plugins)
  167. {
  168. try
  169. {
  170. var metadata = new PluginMetadata
  171. {
  172. File = new FileInfo(Path.Combine(BeatSaber.PluginsPath, plugin)),
  173. IsSelf = false
  174. };
  175. var pluginModule = AssemblyDefinition.ReadAssembly(plugin, new ReaderParameters
  176. {
  177. ReadingMode = ReadingMode.Immediate,
  178. ReadWrite = false,
  179. AssemblyResolver = new CecilLibLoader()
  180. }).MainModule;
  181. string pluginNs = "";
  182. foreach (var resource in pluginModule.Resources)
  183. {
  184. const string manifestSuffix = ".manifest.json";
  185. if (!(resource is EmbeddedResource embedded) ||
  186. !embedded.Name.EndsWith(manifestSuffix)) continue;
  187. pluginNs = embedded.Name.Substring(0, embedded.Name.Length - manifestSuffix.Length);
  188. string manifest;
  189. using (var manifestReader = new StreamReader(embedded.GetResourceStream()))
  190. manifest = manifestReader.ReadToEnd();
  191. metadata.Manifest = JsonConvert.DeserializeObject<PluginManifest>(manifest);
  192. break;
  193. }
  194. if (metadata.Manifest == null)
  195. {
  196. #if DIRE_LOADER_WARNINGS
  197. Logger.loader.Error($"Could not find manifest.json for {Path.GetFileName(plugin)}");
  198. #else
  199. Logger.loader.Notice($"No manifest.json in {Path.GetFileName(plugin)}");
  200. #endif
  201. continue;
  202. }
  203. foreach (var type in pluginModule.Types)
  204. {
  205. if (type.Namespace != pluginNs) continue;
  206. foreach (var inter in type.Interfaces)
  207. {
  208. if (typeof(IBeatSaberPlugin).FullName == inter.InterfaceType.FullName)
  209. {
  210. metadata.PluginType = type;
  211. goto type_loop_done; // break out of both loops
  212. }
  213. }
  214. }
  215. type_loop_done:
  216. if (metadata.PluginType == null)
  217. {
  218. Logger.loader.Error($"No plugin found in the manifest namespace ({pluginNs}) in {Path.GetFileName(plugin)}");
  219. continue;
  220. }
  221. Logger.loader.Debug($"Adding info for {Path.GetFileName(plugin)}");
  222. PluginsMetadata.Add(metadata);
  223. }
  224. catch (Exception e)
  225. {
  226. Logger.loader.Error($"Could not load data for plugin {Path.GetFileName(plugin)}");
  227. Logger.loader.Error(e);
  228. }
  229. }
  230. IEnumerable<string> bareManifests = Directory.GetFiles(BeatSaber.PluginsPath, "*.json");
  231. bareManifests = bareManifests.Concat(Directory.GetFiles(BeatSaber.PluginsPath, "*.manifest"));
  232. foreach (var manifest in bareManifests)
  233. {
  234. try
  235. {
  236. var metadata = new PluginMetadata
  237. {
  238. File = new FileInfo(Path.Combine(BeatSaber.PluginsPath, manifest)),
  239. IsSelf = false,
  240. IsBare = true,
  241. };
  242. metadata.Manifest = JsonConvert.DeserializeObject<PluginManifest>(File.ReadAllText(manifest));
  243. Logger.loader.Debug($"Adding info for bare manifest {Path.GetFileName(manifest)}");
  244. PluginsMetadata.Add(metadata);
  245. }
  246. catch (Exception e)
  247. {
  248. Logger.loader.Error($"Could not load data for bare manifest {Path.GetFileName(manifest)}");
  249. Logger.loader.Error(e);
  250. }
  251. }
  252. foreach (var meta in PluginsMetadata)
  253. { // process description include
  254. var lines = meta.Manifest.Description.Split('\n');
  255. var m = embeddedTextDescriptionPattern.Match(lines[0]);
  256. if (m.Success)
  257. {
  258. if (meta.IsBare)
  259. {
  260. Logger.loader.Warn($"Bare manifest cannot specify description file");
  261. meta.Manifest.Description = string.Join("\n", lines.Skip(1).StrJP()); // ignore first line
  262. continue;
  263. }
  264. var name = m.Groups[1].Value;
  265. string description;
  266. if (!meta.IsSelf)
  267. {
  268. var resc = meta.PluginType.Module.Resources.Select(r => r as EmbeddedResource)
  269. .Where(r => r != null)
  270. .FirstOrDefault(r => r.Name == name);
  271. if (resc == null)
  272. {
  273. Logger.loader.Warn($"Could not find description file for plugin {meta.Name} ({name}); ignoring include");
  274. meta.Manifest.Description = string.Join("\n", lines.Skip(1).StrJP()); // ignore first line
  275. continue;
  276. }
  277. using (var reader = new StreamReader(resc.GetResourceStream()))
  278. description = reader.ReadToEnd();
  279. }
  280. else
  281. {
  282. using (var descriptionReader =
  283. new StreamReader(
  284. meta.Assembly.GetManifestResourceStream(name) ??
  285. throw new InvalidOperationException()))
  286. description = descriptionReader.ReadToEnd();
  287. }
  288. meta.Manifest.Description = description;
  289. }
  290. }
  291. }
  292. // keep track of these for the updater; it should still be able to update mods not loaded
  293. // TODO: add ignore reason
  294. internal static HashSet<PluginMetadata> ignoredPlugins = new HashSet<PluginMetadata>();
  295. internal static void Resolve()
  296. { // resolves duplicates and conflicts, etc
  297. PluginsMetadata.Sort((a, b) => b.Version.CompareTo(a.Version));
  298. var ids = new HashSet<string>();
  299. var ignore = new HashSet<PluginMetadata>();
  300. var resolved = new List<PluginMetadata>(PluginsMetadata.Count);
  301. foreach (var meta in PluginsMetadata)
  302. {
  303. if (meta.Id != null)
  304. {
  305. if (ids.Contains(meta.Id))
  306. {
  307. Logger.loader.Warn($"Found duplicates of {meta.Id}, using newest");
  308. ignore.Add(meta);
  309. ignoredPlugins.Add(meta);
  310. continue; // because of sorted order, hightest order will always be the first one
  311. }
  312. bool processedLater = false;
  313. foreach (var meta2 in PluginsMetadata)
  314. {
  315. if (ignore.Contains(meta2)) continue;
  316. if (meta == meta2)
  317. {
  318. processedLater = true;
  319. continue;
  320. }
  321. if (!meta2.Manifest.Conflicts.ContainsKey(meta.Id)) continue;
  322. var range = meta2.Manifest.Conflicts[meta.Id];
  323. if (!range.IsSatisfied(meta.Version)) continue;
  324. Logger.loader.Warn($"{meta.Id}@{meta.Version} conflicts with {meta2.Name}");
  325. if (processedLater)
  326. {
  327. Logger.loader.Warn($"Ignoring {meta2.Name}");
  328. ignore.Add(meta2);
  329. }
  330. else
  331. {
  332. Logger.loader.Warn($"Ignoring {meta.Name}");
  333. ignore.Add(meta);
  334. break;
  335. }
  336. }
  337. }
  338. if (ignore.Contains(meta))
  339. {
  340. ignoredPlugins.Add(meta);
  341. continue;
  342. }
  343. if (meta.Id != null)
  344. ids.Add(meta.Id);
  345. resolved.Add(meta);
  346. }
  347. PluginsMetadata = resolved;
  348. }
  349. private static void FilterDisabled()
  350. {
  351. var enabled = new List<PluginMetadata>(PluginsMetadata.Count);
  352. var disabled = DisabledConfig.Ref.Value.DisabledModIds;
  353. foreach (var meta in PluginsMetadata)
  354. {
  355. if (disabled.Contains(meta.Id ?? meta.Name))
  356. DisabledPlugins.Add(meta);
  357. else
  358. enabled.Add(meta);
  359. }
  360. PluginsMetadata = enabled;
  361. }
  362. internal static void ComputeLoadOrder()
  363. {
  364. #if DEBUG
  365. Logger.loader.Debug(string.Join(", ", PluginsMetadata.Select(p => p.ToString()).StrJP()));
  366. #endif
  367. bool InsertInto(HashSet<PluginMetadata> root, PluginMetadata meta, bool isRoot = false)
  368. { // this is slow, and hella recursive
  369. bool inserted = false;
  370. foreach (var sr in root)
  371. {
  372. inserted = inserted || InsertInto(sr.Dependencies, meta);
  373. if (meta.Id != null)
  374. if (sr.Manifest.Dependencies.ContainsKey(meta.Id) || sr.Manifest.LoadAfter.Contains(meta.Id))
  375. inserted = inserted || sr.Dependencies.Add(meta);
  376. if (sr.Id != null)
  377. if (meta.Manifest.LoadBefore.Contains(sr.Id))
  378. inserted = inserted || sr.Dependencies.Add(meta);
  379. }
  380. if (isRoot)
  381. {
  382. foreach (var sr in root)
  383. {
  384. InsertInto(meta.Dependencies, sr);
  385. if (sr.Id != null)
  386. if (meta.Manifest.Dependencies.ContainsKey(sr.Id) || meta.Manifest.LoadAfter.Contains(sr.Id))
  387. meta.Dependencies.Add(sr);
  388. if (meta.Id != null)
  389. if (sr.Manifest.LoadBefore.Contains(meta.Id))
  390. meta.Dependencies.Add(sr);
  391. }
  392. root.Add(meta);
  393. }
  394. return inserted;
  395. }
  396. var pluginTree = new HashSet<PluginMetadata>();
  397. foreach (var meta in PluginsMetadata)
  398. InsertInto(pluginTree, meta, true);
  399. void DeTree(List<PluginMetadata> into, HashSet<PluginMetadata> tree)
  400. {
  401. foreach (var st in tree)
  402. if (!into.Contains(st))
  403. {
  404. DeTree(into, st.Dependencies);
  405. into.Add(st);
  406. }
  407. }
  408. PluginsMetadata = new List<PluginMetadata>();
  409. DeTree(PluginsMetadata, pluginTree);
  410. #if DEBUG
  411. Logger.loader.Debug(string.Join(", ", PluginsMetadata.Select(p => p.ToString()).StrJP()));
  412. #endif
  413. }
  414. internal static void ResolveDependencies()
  415. {
  416. var metadata = new List<PluginMetadata>();
  417. var pluginsToLoad = new Dictionary<string, Version>();
  418. var disabledLookup = DisabledPlugins.Where(m => m.Id != null).ToDictionary(m => m.Id, m => m.Version);
  419. foreach (var meta in PluginsMetadata)
  420. {
  421. bool load = true;
  422. bool disable = false;
  423. foreach (var dep in meta.Manifest.Dependencies)
  424. {
  425. #if DEBUG
  426. Logger.loader.Debug($"Looking for dependency {dep.Key} with version range {dep.Value.Intersect(new SemVer.Range("*.*.*"))}");
  427. #endif
  428. if (pluginsToLoad.ContainsKey(dep.Key) && dep.Value.IsSatisfied(pluginsToLoad[dep.Key]))
  429. continue;
  430. load = false;
  431. if (disabledLookup.ContainsKey(dep.Key) && dep.Value.IsSatisfied(disabledLookup[dep.Key]))
  432. {
  433. disable = true;
  434. Logger.loader.Warn($"Dependency {dep.Key} was found, but disabled. Disabling {meta.Name} too.");
  435. }
  436. else
  437. Logger.loader.Warn($"{meta.Name} is missing dependency {dep.Key}@{dep.Value}");
  438. break;
  439. }
  440. if (load)
  441. {
  442. metadata.Add(meta);
  443. if (meta.Id != null)
  444. pluginsToLoad.Add(meta.Id, meta.Version);
  445. }
  446. else if (disable)
  447. {
  448. DisabledPlugins.Add(meta);
  449. DisabledConfig.Ref.Value.DisabledModIds.Add(meta.Id ?? meta.Name);
  450. }
  451. else
  452. ignoredPlugins.Add(meta);
  453. }
  454. PluginsMetadata = metadata;
  455. }
  456. internal static void InitFeatures()
  457. {
  458. var parsedFeatures = PluginsMetadata.Select(m =>
  459. Tuple.Create(m,
  460. m.Manifest.Features.Select(f =>
  461. Tuple.Create(f, Ref.Create<Feature.FeatureParse?>(null))
  462. ).ToList()
  463. )
  464. ).ToList();
  465. while (DefineFeature.NewFeature)
  466. {
  467. DefineFeature.NewFeature = false;
  468. foreach (var plugin in parsedFeatures)
  469. for (var i = 0; i < plugin.Item2.Count; i++)
  470. {
  471. var feature = plugin.Item2[i];
  472. var success = Feature.TryParseFeature(feature.Item1, plugin.Item1, out var featureObj,
  473. out var exception, out var valid, out var parsed, feature.Item2.Value);
  474. if (!success && !valid && featureObj == null && exception == null) // no feature of type found
  475. feature.Item2.Value = parsed;
  476. else if (success)
  477. {
  478. if (valid && featureObj.StoreOnPlugin)
  479. plugin.Item1.InternalFeatures.Add(featureObj);
  480. else if (!valid)
  481. Logger.features.Warn(
  482. $"Feature not valid on {plugin.Item1.Name}: {featureObj.InvalidMessage}");
  483. plugin.Item2.RemoveAt(i--);
  484. }
  485. else
  486. {
  487. Logger.features.Error($"Error parsing feature definition on {plugin.Item1.Name}");
  488. Logger.features.Error(exception);
  489. plugin.Item2.RemoveAt(i--);
  490. }
  491. }
  492. foreach (var plugin in PluginsMetadata)
  493. foreach (var feature in plugin.Features)
  494. feature.Evaluate();
  495. }
  496. foreach (var plugin in parsedFeatures)
  497. {
  498. if (plugin.Item2.Count <= 0) continue;
  499. Logger.features.Warn($"On plugin {plugin.Item1.Name}:");
  500. foreach (var feature in plugin.Item2)
  501. Logger.features.Warn($" Feature not found with name {feature.Item1}");
  502. }
  503. }
  504. internal static void ReleaseAll(bool full = false)
  505. {
  506. if (full)
  507. ignoredPlugins = new HashSet<PluginMetadata>();
  508. else
  509. {
  510. foreach (var m in PluginsMetadata)
  511. ignoredPlugins.Add(m);
  512. foreach (var m in ignoredPlugins)
  513. { // clean them up so we can still use the metadata for updates
  514. m.InternalFeatures.Clear();
  515. m.PluginType = null;
  516. m.Assembly = null;
  517. }
  518. }
  519. PluginsMetadata = new List<PluginMetadata>();
  520. DisabledPlugins = new List<PluginMetadata>();
  521. Feature.Reset();
  522. GC.Collect();
  523. }
  524. internal static void Load(PluginMetadata meta)
  525. {
  526. if (meta.Assembly == null && meta.PluginType != null)
  527. meta.Assembly = Assembly.LoadFrom(meta.File.FullName);
  528. }
  529. internal static PluginInfo InitPlugin(PluginMetadata meta)
  530. {
  531. if (meta.PluginType == null)
  532. return new PluginInfo()
  533. {
  534. Metadata = meta,
  535. Plugin = null
  536. };
  537. var info = new PluginInfo();
  538. if (meta.Manifest.GameVersion != BeatSaber.GameVersion)
  539. Logger.loader.Warn($"Mod {meta.Name} developed for game version {meta.Manifest.GameVersion}, so it may not work properly.");
  540. try
  541. {
  542. Load(meta);
  543. Feature denyingFeature = null;
  544. if (!meta.Features.All(f => (denyingFeature = f).BeforeLoad(meta)))
  545. {
  546. Logger.loader.Warn(
  547. $"Feature {denyingFeature?.GetType()} denied plugin {meta.Name} from loading! {denyingFeature?.InvalidMessage}");
  548. ignoredPlugins.Add(meta);
  549. return null;
  550. }
  551. var type = meta.Assembly.GetType(meta.PluginType.FullName);
  552. var instance = (IBeatSaberPlugin)Activator.CreateInstance(type);
  553. info.Metadata = meta;
  554. info.Plugin = instance;
  555. var init = type.GetMethod("Init", BindingFlags.Instance | BindingFlags.Public);
  556. if (init != null)
  557. {
  558. denyingFeature = null;
  559. if (!meta.Features.All(f => (denyingFeature = f).BeforeInit(info)))
  560. {
  561. Logger.loader.Warn(
  562. $"Feature {denyingFeature?.GetType()} denied plugin {meta.Name} from initializing! {denyingFeature?.InvalidMessage}");
  563. ignoredPlugins.Add(meta);
  564. return null;
  565. }
  566. PluginInitInjector.Inject(init, info);
  567. }
  568. foreach (var feature in meta.Features)
  569. try
  570. {
  571. feature.AfterInit(info, info.Plugin);
  572. }
  573. catch (Exception e)
  574. {
  575. Logger.loader.Critical($"Feature errored in {nameof(Feature.AfterInit)}: {e}");
  576. }
  577. if (instance is IDisablablePlugin disable)
  578. try // TODO: move this out to after all plugins have been inited
  579. {
  580. disable.OnEnable();
  581. }
  582. catch (Exception e)
  583. {
  584. Logger.loader.Error($"Error occurred trying to enable {meta.Name}");
  585. Logger.loader.Error(e);
  586. }
  587. }
  588. catch (AmbiguousMatchException)
  589. {
  590. Logger.loader.Error($"Only one Init allowed per plugin (ambiguous match in {meta.Name})");
  591. // not adding to ignoredPlugins here because this should only happen in a development context
  592. // if someone fucks this up on release thats on them
  593. return null;
  594. }
  595. catch (Exception e)
  596. {
  597. Logger.loader.Error($"Could not init plugin {meta.Name}: {e}");
  598. ignoredPlugins.Add(meta);
  599. return null;
  600. }
  601. return info;
  602. }
  603. internal static List<PluginInfo> LoadPlugins()
  604. {
  605. InitFeatures();
  606. DisabledPlugins.ForEach(Load); // make sure they get loaded into memory so their metadata and stuff can be read more easily
  607. return PluginsMetadata.Select(InitPlugin).Where(p => p != null).ToList();
  608. }
  609. }
  610. }