diff --git a/marketplace/plugins.json b/marketplace/plugins.json index 5560e06..5de94f3 100644 --- a/marketplace/plugins.json +++ b/marketplace/plugins.json @@ -39,7 +39,7 @@ ] }, { - "id": "duck.hayashiume.friendcodevalidator", + "id": "duck.Empostor.friendcodevalidator", "name": "Friend Code Validator", "description": "Kicks clients whose friend code does not match the official AB+#XXXX format.", "author": "MatchDuck & HayashiUme", @@ -52,7 +52,7 @@ ] }, { - "id": "cn.hayashiume.fixedcode", + "id": "cn.Empostor.fixedcode", "name": "Fixed Room Code", "description": "Assigns a fixed room code to a host based on their friend code.", "author": "HayashiUme", @@ -65,7 +65,7 @@ ] }, { - "id": "cn.hayashiume.titles", + "id": "cn.Empostor.titles", "name": "Custom Title", "description": "Assigns a title based on their friend code and show in front of their name.", "author": "HayashiUme", diff --git a/src/Empostor.Server/Http/MarketplaceController.cs b/src/Empostor.Server/Http/MarketplaceController.cs index 9fa7bd4..cc45b81 100644 --- a/src/Empostor.Server/Http/MarketplaceController.cs +++ b/src/Empostor.Server/Http/MarketplaceController.cs @@ -47,6 +47,10 @@ namespace Empostor.Server.Http private bool IsAuthenticated() => AdminSession.IsAuthenticated(HttpContext, _passwordHash); + private HashSet GetLoadedPluginIds() => new( + _pluginLoaderService.Plugins.Where(p => p.IsLoaded).Select(p => p.Id), + StringComparer.OrdinalIgnoreCase); + [HttpGet("/api/admin/marketplace/plugins")] public async Task ListPlugins() { @@ -66,9 +70,7 @@ namespace Empostor.Server.Http using var client = CreateClient(); var json = await client.GetStringAsync(url); - var installedIds = new HashSet( - _pluginLoaderService.Plugins.Select(p => p.Id), - StringComparer.OrdinalIgnoreCase); + var installedIds = GetLoadedPluginIds(); using var doc = JsonDocument.Parse(json); var plugins = new List(); @@ -123,9 +125,7 @@ namespace Empostor.Server.Http if (!string.IsNullOrEmpty(req.PluginId)) { - var installedIds = new HashSet( - _pluginLoaderService.Plugins.Select(p => p.Id), - StringComparer.OrdinalIgnoreCase); + var installedIds = GetLoadedPluginIds(); if (installedIds.Contains(req.PluginId)) { diff --git a/src/Empostor.Server/Plugins/PluginInformation.cs b/src/Empostor.Server/Plugins/PluginInformation.cs index 20afe55..5a3ebae 100644 --- a/src/Empostor.Server/Plugins/PluginInformation.cs +++ b/src/Empostor.Server/Plugins/PluginInformation.cs @@ -48,6 +48,8 @@ namespace Empostor.Server.Plugins public IPlugin? Instance { get; set; } + public bool IsLoaded { get; internal set; } + public override string ToString() => $"{Id} {Name} ({Version}) by {Author}"; } } diff --git a/src/Empostor.Server/Plugins/PluginLoaderService.cs b/src/Empostor.Server/Plugins/PluginLoaderService.cs index 5459164..39b216f 100644 --- a/src/Empostor.Server/Plugins/PluginLoaderService.cs +++ b/src/Empostor.Server/Plugins/PluginLoaderService.cs @@ -42,6 +42,7 @@ namespace Empostor.Server.Plugins plugin.Instance = instance; await plugin.Instance.EnableAsync(); + plugin.IsLoaded = true; } @@ -58,6 +59,7 @@ namespace Empostor.Server.Plugins { _logger.LogInformation("Disabling plugin {0}.", plugin); await plugin.Instance.DisableAsync(); + plugin.IsLoaded = false; } } }