fix update plugins issue

This commit is contained in:
linmeideli committed 2026-10-07 10:42:15 +08:00
1 parent 453ebbdf70
commit 46495ed501
4 files changed
+13 -9

No files matched your search

+3 -3
View File
@@ -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",
@@ -47,6 +47,10 @@ namespace Empostor.Server.Http
private bool IsAuthenticated() => AdminSession.IsAuthenticated(HttpContext, _passwordHash);
private HashSet<string> GetLoadedPluginIds() => new(
_pluginLoaderService.Plugins.Where(p => p.IsLoaded).Select(p => p.Id),
StringComparer.OrdinalIgnoreCase);
[HttpGet("/api/admin/marketplace/plugins")]
public async Task<IActionResult> ListPlugins()
{
@@ -66,9 +70,7 @@ namespace Empostor.Server.Http
using var client = CreateClient();
var json = await client.GetStringAsync(url);
var installedIds = new HashSet<string>(
_pluginLoaderService.Plugins.Select(p => p.Id),
StringComparer.OrdinalIgnoreCase);
var installedIds = GetLoadedPluginIds();
using var doc = JsonDocument.Parse(json);
var plugins = new List<JsonElement>();
@@ -123,9 +125,7 @@ namespace Empostor.Server.Http
if (!string.IsNullOrEmpty(req.PluginId))
{
var installedIds = new HashSet<string>(
_pluginLoaderService.Plugins.Select(p => p.Id),
StringComparer.OrdinalIgnoreCase);
var installedIds = GetLoadedPluginIds();
if (installedIds.Contains(req.PluginId))
{
@@ -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}";
}
}
@@ -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;
}
}
}