From c093a701f88e07e045e970dc3759e31d1362cf34 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sat, 6 Jan 2024 12:11:06 +0000 Subject: [PATCH] fix: suppress events if current world is null --- VPLink/Services/VirtualParadiseMessageService.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/VPLink/Services/VirtualParadiseMessageService.cs b/VPLink/Services/VirtualParadiseMessageService.cs index 48f0117..c730b01 100644 --- a/VPLink/Services/VirtualParadiseMessageService.cs +++ b/VPLink/Services/VirtualParadiseMessageService.cs @@ -43,6 +43,8 @@ internal sealed class VirtualParadiseMessageService : BackgroundService, IVirtua /// 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;