1
0
mirror of https://github.com/oliverbooth/VPLink synced 2024-11-22 19:38:47 +00:00

fix: suppress events if current world is null

This commit is contained in:
Oliver Booth 2024-01-06 12:11:06 +00:00
parent 1008d267cc
commit c093a701f8
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5

View File

@ -43,6 +43,8 @@ internal sealed class VirtualParadiseMessageService : BackgroundService, IVirtua
/// <inheritdoc />
public Task SendMessageAsync(RelayedMessage message)
{
if (_virtualParadiseClient.CurrentWorld is null) return Task.CompletedTask;
IChatConfiguration configuration = _configurationService.VirtualParadiseConfiguration.Chat;
Color color = Color.FromArgb((int)(message.IsReply ? configuration.ReplyColor : configuration.Color));
@ -62,6 +64,7 @@ internal sealed class VirtualParadiseMessageService : BackgroundService, IVirtua
private void OnVPMessageReceived(VirtualParadiseMessage message)
{
if (message is null) throw new ArgumentNullException(nameof(message));
if (_virtualParadiseClient.CurrentWorld is null) return;
if (message.Type != MessageType.ChatMessage) return;
if (message.Author == _virtualParadiseClient.CurrentAvatar) return;
if (message.Author.IsBot && !_configurationService.BotConfiguration.RelayBotMessages) return;