Skip to content

Commit

Permalink
fix: suppress events if current world is null
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Jan 6, 2024
1 parent 1008d26 commit c093a70
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions VPLink/Services/VirtualParadiseMessageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public VirtualParadiseMessageService(ILogger<VirtualParadiseMessageService> logg
/// <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));
Expand All @@ -62,6 +64,7 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken)
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;
Expand Down

0 comments on commit c093a70

Please sign in to comment.