public void Load(CompilablePlugin plugin) { plugin.Compile(compiled => { if (!compiled) { PluginLoadingCompleted(plugin); return; } var loadedLoadingRequirements = plugin.Requires.Where(r => LoadedPlugins.ContainsKey(r) && LoadingPlugins.Contains(r)); foreach (var loadedPlugin in loadedLoadingRequirements) { Interface.Oxide.UnloadPlugin(loadedPlugin); } var missingRequirements = plugin.Requires.Where(r => !LoadedPlugins.ContainsKey(r)); if (missingRequirements.Any()) { var loadingRequirements = plugin.Requires.Where(r => LoadingPlugins.Contains(r)); if (loadingRequirements.Any()) { Interface.Oxide.LogDebug($"{plugin.Name} plugin is waiting for requirements to be loaded: {loadingRequirements.ToSentence()}"); } else { Interface.Oxide.LogError($"{plugin.Name} plugin requires missing dependencies: {missingRequirements.ToSentence()}"); PluginErrors[plugin.Name] = $"Missing dependencies: {missingRequirements.ToSentence()}"; PluginLoadingCompleted(plugin); } } else { Interface.Oxide.UnloadPlugin(plugin.Name); plugin.LoadPlugin(pl => { if (pl != null) { LoadedPlugins[pl.Name] = pl; } PluginLoadingCompleted(plugin); }); } }); }