fix issue with help page not showing v2 commands
This commit is contained in:
parent
466ae96874
commit
740df7c3ee
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Diagnostics;
|
using Microsoft.AspNetCore.Diagnostics;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SharedLibraryCore;
|
using SharedLibraryCore;
|
||||||
@ -18,13 +19,17 @@ namespace WebfrontCore.Controllers
|
|||||||
private readonly ITranslationLookup _translationLookup;
|
private readonly ITranslationLookup _translationLookup;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IServerDataViewer _serverDataViewer;
|
private readonly IServerDataViewer _serverDataViewer;
|
||||||
|
private readonly ILookup<Type, string> _pluginTypeNames;
|
||||||
|
|
||||||
public HomeController(ILogger<HomeController> logger, IManager manager, ITranslationLookup translationLookup,
|
public HomeController(ILogger<HomeController> logger, IManager manager, ITranslationLookup translationLookup,
|
||||||
IServerDataViewer serverDataViewer) : base(manager)
|
IServerDataViewer serverDataViewer, IEnumerable<IPlugin> v1Plugins, IEnumerable<IPluginV2> v2Plugins) : base(manager)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_translationLookup = translationLookup;
|
_translationLookup = translationLookup;
|
||||||
_serverDataViewer = serverDataViewer;
|
_serverDataViewer = serverDataViewer;
|
||||||
|
_pluginTypeNames = v1Plugins.Select(plugin => (plugin.GetType(), plugin.Name))
|
||||||
|
.Concat(v2Plugins.Select(plugin => (plugin.GetType(), plugin.Name)))
|
||||||
|
.ToLookup(selector => selector.Item1, selector => selector.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> Index(Reference.Game? game = null,
|
public async Task<IActionResult> Index(Reference.Game? game = null,
|
||||||
@ -96,9 +101,9 @@ namespace WebfrontCore.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pluginType = command.GetType().Assembly.GetTypes()
|
var pluginType = command.GetType().Assembly.GetTypes()
|
||||||
.FirstOrDefault(type => typeof(IPlugin).IsAssignableFrom(type));
|
.FirstOrDefault(type => typeof(IPlugin).IsAssignableFrom(type) || typeof(IPluginV2).IsAssignableFrom(type));
|
||||||
return Manager.Plugins.FirstOrDefault(plugin => plugin.GetType() == pluginType)?.Name ??
|
|
||||||
_translationLookup["WEBFRONT_HELP_COMMAND_NATIVE"];
|
return _pluginTypeNames[pluginType].FirstOrDefault() ?? _translationLookup["WEBFRONT_HELP_COMMAND_NATIVE"];
|
||||||
})
|
})
|
||||||
.Select(group => (group.Key, group.AsEnumerable()));
|
.Select(group => (group.Key, group.AsEnumerable()));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user