before candybox editor update
This commit is contained in:
@@ -9,14 +9,9 @@ namespace VisionBuilder.UI.Common.Plugins;
|
||||
[ModulePriority(1000)]
|
||||
public class PluginLoader:IVisionBuilderModule
|
||||
{
|
||||
private readonly PluginSettings _settings;
|
||||
|
||||
|
||||
|
||||
const string PLUGINS_DIRECTORY = "Plugins";
|
||||
public PluginLoader(PluginSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public List<IPlugin> Plugins { get; } = new List<IPlugin>();
|
||||
|
||||
@@ -31,6 +26,15 @@ public class PluginLoader:IVisionBuilderModule
|
||||
_isInitialized = true;
|
||||
Log.Information("Loading plugins...");
|
||||
var pluginsPath = Path.Combine("..", "Data", PLUGINS_DIRECTORY);
|
||||
|
||||
var enabledPluginsPath = Path.Combine(pluginsPath, "enabled_plugins.txt");
|
||||
if (!File.Exists(enabledPluginsPath))
|
||||
{
|
||||
Log.Warning("Enabled plugins file not found: {EnabledPluginsPath}. All discovered plugins will be disabled by default.", enabledPluginsPath);
|
||||
File.WriteAllText(enabledPluginsPath, "");
|
||||
}
|
||||
|
||||
List<string> enabledPlugins = File.ReadAllLines(enabledPluginsPath).ToList();
|
||||
Directory.CreateDirectory(pluginsPath);
|
||||
var pluginFolders = Directory.GetDirectories(pluginsPath);
|
||||
|
||||
@@ -38,13 +42,8 @@ public class PluginLoader:IVisionBuilderModule
|
||||
{
|
||||
var pluginName = Path.GetFileNameWithoutExtension(folder);
|
||||
|
||||
if (_settings.Plugins.All(p => p.Name != pluginName))
|
||||
{
|
||||
Log.Warning("Discovered new plugin:{PluginName}. Adding to settings.", pluginName);
|
||||
_settings.AddPlugin(new PluginSettings.PluginFlag { Name = pluginName, Enabled = false });
|
||||
}
|
||||
|
||||
if (_settings.Plugins.Where(p => p.Name == pluginName).All(x=>!x.Enabled))
|
||||
if (!enabledPlugins.Contains(pluginName))
|
||||
{
|
||||
Log.Information("Skipping plugin {PluginName} as it is not enabled in settings.", pluginName);
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user