From 85d44b0eb0a5d03fda620314f02266e572ab59e4 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 23 Mar 2022 12:09:40 -0500 Subject: [PATCH] fix issue with multi line output freezing console --- .../Commands/ClientTags/ListClientTags.cs | 3 ++- Application/Commands/ListClientsCommand.cs | 4 ++-- Plugins/AutomessageFeed/AutomessageFeed.csproj | 2 +- Plugins/Login/Login.csproj | 2 +- .../ProfanityDeterment/ProfanityDeterment.csproj | 2 +- Plugins/Stats/Commands/MostKillsCommand.cs | 14 ++++++-------- Plugins/Stats/Commands/MostPlayedCommand.cs | 16 +++++----------- Plugins/Stats/Commands/TopStats.cs | 16 +++++++--------- Plugins/Stats/Stats.csproj | 2 +- Plugins/Welcome/Welcome.csproj | 2 +- 10 files changed, 27 insertions(+), 36 deletions(-) diff --git a/Application/Commands/ClientTags/ListClientTags.cs b/Application/Commands/ClientTags/ListClientTags.cs index ac61de095..dafa988b1 100644 --- a/Application/Commands/ClientTags/ListClientTags.cs +++ b/Application/Commands/ClientTags/ListClientTags.cs @@ -30,7 +30,8 @@ namespace IW4MAdmin.Application.Commands.ClientTags if (tags is not null) { - gameEvent.Origin.Tell(tags.Select(tag => tag.TagName)); + await gameEvent.Origin.TellAsync(tags.Select(tag => tag.TagName), + gameEvent.Owner.Manager.CancellationToken); } } } diff --git a/Application/Commands/ListClientsCommand.cs b/Application/Commands/ListClientsCommand.cs index 271e05019..56035546b 100644 --- a/Application/Commands/ListClientsCommand.cs +++ b/Application/Commands/ListClientsCommand.cs @@ -29,9 +29,9 @@ namespace IW4MAdmin.Application.Commands $"[(Color::Accent){client.ClientPermission.Name}(Color::White){(string.IsNullOrEmpty(client.Tag) ? "" : $" {client.Tag}")}(Color::White)][(Color::Yellow)#{client.ClientNumber}(Color::White)] {client.Name}") .ToArray(); - gameEvent.Origin.Tell(clientList); + gameEvent.Origin.TellAsync(clientList, gameEvent.Owner.Manager.CancellationToken); return Task.CompletedTask; } } -} \ No newline at end of file +} diff --git a/Plugins/AutomessageFeed/AutomessageFeed.csproj b/Plugins/AutomessageFeed/AutomessageFeed.csproj index 88bda769d..06cfea74f 100644 --- a/Plugins/AutomessageFeed/AutomessageFeed.csproj +++ b/Plugins/AutomessageFeed/AutomessageFeed.csproj @@ -10,7 +10,7 @@ - + diff --git a/Plugins/Login/Login.csproj b/Plugins/Login/Login.csproj index 4ffa9ed54..b3c4555f5 100644 --- a/Plugins/Login/Login.csproj +++ b/Plugins/Login/Login.csproj @@ -19,7 +19,7 @@ - + diff --git a/Plugins/ProfanityDeterment/ProfanityDeterment.csproj b/Plugins/ProfanityDeterment/ProfanityDeterment.csproj index d3a465baa..41a82fce2 100644 --- a/Plugins/ProfanityDeterment/ProfanityDeterment.csproj +++ b/Plugins/ProfanityDeterment/ProfanityDeterment.csproj @@ -16,7 +16,7 @@ - + diff --git a/Plugins/Stats/Commands/MostKillsCommand.cs b/Plugins/Stats/Commands/MostKillsCommand.cs index 5ff543eb0..354cf5c02 100644 --- a/Plugins/Stats/Commands/MostKillsCommand.cs +++ b/Plugins/Stats/Commands/MostKillsCommand.cs @@ -29,23 +29,21 @@ namespace IW4MAdmin.Plugins.Stats.Commands _contextFactory = contextFactory; } - public override async Task ExecuteAsync(GameEvent E) + public override async Task ExecuteAsync(GameEvent gameEvent) { - var mostKills = await GetMostKills(StatManager.GetIdForServer(E.Owner), Plugin.Config.Configuration(), + var mostKills = await GetMostKills(StatManager.GetIdForServer(gameEvent.Owner), Plugin.Config.Configuration(), _contextFactory, _translationLookup); - if (!E.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix)) + if (!gameEvent.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix)) { - foreach (var stat in mostKills) - { - E.Origin.Tell(stat); - } + await gameEvent.Origin.TellAsync(mostKills, gameEvent.Owner.Manager.CancellationToken); } else { foreach (var stat in mostKills) { - E.Owner.Broadcast(stat); + await gameEvent.Owner.Broadcast(stat).WaitAsync(Utilities.DefaultCommandTimeout, + gameEvent.Owner.Manager.CancellationToken); } } } diff --git a/Plugins/Stats/Commands/MostPlayedCommand.cs b/Plugins/Stats/Commands/MostPlayedCommand.cs index a45dc71b1..23887d4fb 100644 --- a/Plugins/Stats/Commands/MostPlayedCommand.cs +++ b/Plugins/Stats/Commands/MostPlayedCommand.cs @@ -70,22 +70,16 @@ namespace IW4MAdmin.Plugins.Stats.Commands _contextFactory = contextFactory; } - public override async Task ExecuteAsync(GameEvent E) + public override async Task ExecuteAsync(GameEvent gameEvent) { - var topStats = await GetMostPlayed(E.Owner, _translationLookup, _contextFactory); - if (!E.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix)) + var topStats = await GetMostPlayed(gameEvent.Owner, _translationLookup, _contextFactory); + if (!gameEvent.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix)) { - foreach (var stat in topStats) - { - E.Origin.Tell(stat); - } + await gameEvent.Origin.TellAsync(topStats, gameEvent.Owner.Manager.CancellationToken); } else { - foreach (var stat in topStats) - { - E.Owner.Broadcast(stat); - } + gameEvent.Owner.Broadcast(topStats); } } } diff --git a/Plugins/Stats/Commands/TopStats.cs b/Plugins/Stats/Commands/TopStats.cs index 4cb4607bd..cf012f9a5 100644 --- a/Plugins/Stats/Commands/TopStats.cs +++ b/Plugins/Stats/Commands/TopStats.cs @@ -52,23 +52,21 @@ namespace IW4MAdmin.Plugins.Stats.Commands _config = config; } - public override async Task ExecuteAsync(GameEvent E) + public override async Task ExecuteAsync(GameEvent gameEvent) { - var topStats = await GetTopStats(E.Owner, _translationLookup); - if (!E.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix)) + var topStats = await GetTopStats(gameEvent.Owner, _translationLookup); + if (!gameEvent.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix)) { - foreach (var stat in topStats) - { - E.Origin.Tell(stat); - } + await gameEvent.Origin.TellAsync(topStats, gameEvent.Owner.Manager.CancellationToken); } else { foreach (var stat in topStats) { - E.Owner.Broadcast(stat); + await gameEvent.Owner.Broadcast(stat).WaitAsync(Utilities.DefaultCommandTimeout, + gameEvent.Owner.Manager.CancellationToken); } } } } -} \ No newline at end of file +} diff --git a/Plugins/Stats/Stats.csproj b/Plugins/Stats/Stats.csproj index 975218976..35f2e76df 100644 --- a/Plugins/Stats/Stats.csproj +++ b/Plugins/Stats/Stats.csproj @@ -17,7 +17,7 @@ - + diff --git a/Plugins/Welcome/Welcome.csproj b/Plugins/Welcome/Welcome.csproj index 2fa4192a3..a9f287bb3 100644 --- a/Plugins/Welcome/Welcome.csproj +++ b/Plugins/Welcome/Welcome.csproj @@ -20,7 +20,7 @@ - +