mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 16:39:21 +01:00
Fix CustomCommands never getting their ICustomCommandHandler
This commit is contained in:
@@ -645,6 +645,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
IChatTrackingContext context = null;
|
||||
lock (mappedChannels)
|
||||
context = new ChatTrackingContext(
|
||||
customCommandHandler,
|
||||
mappedChannels.Select(y => y.Value.Channel),
|
||||
loggerFactory.CreateLogger<ChatTrackingContext>(),
|
||||
() =>
|
||||
|
||||
@@ -26,7 +26,22 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
public IReadOnlyCollection<ChannelRepresentation> Channels { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<CustomCommand> CustomCommands { get; set; }
|
||||
public IEnumerable<CustomCommand> CustomCommands
|
||||
{
|
||||
get => customCommands;
|
||||
set => customCommands = (value ?? throw new InvalidOperationException("value cannot be null!"))
|
||||
.Select(customCommand =>
|
||||
{
|
||||
customCommand.SetHandler(customCommandHandler);
|
||||
return customCommand;
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ICustomCommandHandler"/> for the <see cref="ChatTrackingContext"/>.
|
||||
/// </summary>
|
||||
readonly ICustomCommandHandler customCommandHandler;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ILogger"/> for the <see cref="ChatTrackingContext"/>.
|
||||
@@ -38,6 +53,11 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// </summary>
|
||||
readonly object synchronizationLock;
|
||||
|
||||
/// <summary>
|
||||
/// Backing field for <see cref="CustomCommands"/>.
|
||||
/// </summary>
|
||||
IReadOnlyCollection<CustomCommand> customCommands;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IChannelSink"/> if any.
|
||||
/// </summary>
|
||||
@@ -56,20 +76,24 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChatTrackingContext"/> <see langword="class"/>.
|
||||
/// </summary>
|
||||
/// <param name="customCommandHandler">The value of <see cref="customCommandHandler"/>.</param>
|
||||
/// <param name="initialChannels">The initial value of <see cref="Channels"/>.</param>
|
||||
/// <param name="logger">The value of <see cref="logger"/>.</param>
|
||||
/// <param name="onDispose">The value of <see cref="onDispose"/>.</param>
|
||||
public ChatTrackingContext(
|
||||
ICustomCommandHandler customCommandHandler,
|
||||
IEnumerable<ChannelRepresentation> initialChannels,
|
||||
ILogger<ChatTrackingContext> logger,
|
||||
Action onDispose)
|
||||
{
|
||||
this.customCommandHandler = customCommandHandler ?? throw new ArgumentNullException(nameof(customCommandHandler));
|
||||
Channels = initialChannels?.ToList() ?? throw new ArgumentNullException(nameof(initialChannels));
|
||||
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
this.onDispose = onDispose ?? throw new ArgumentNullException(nameof(onDispose));
|
||||
|
||||
synchronizationLock = new object();
|
||||
Active = true;
|
||||
customCommands = Array.Empty<CustomCommand>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// <summary>
|
||||
/// <see cref="IReadOnlyCollection{T}"/> of <see cref="CustomCommand"/>s in the <see cref="IChatTrackingContext"/>.
|
||||
/// </summary>
|
||||
IReadOnlyCollection<CustomCommand> CustomCommands { get; set; }
|
||||
IEnumerable<CustomCommand> CustomCommands { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the <paramref name="channelSink"/> for the <see cref="IChatTrackingContext"/>.
|
||||
|
||||
Reference in New Issue
Block a user