add offline messaging feature
This commit is contained in:
@ -35,7 +35,7 @@ namespace SharedLibraryCore.Commands
|
||||
|
||||
if (!gameEvent.CanPerformActionOnTarget())
|
||||
{
|
||||
gameEvent.Origin.Tell(_translationLookup["COMMANDS_RUN_AS_FAIL_PERM"]);
|
||||
gameEvent.Origin.Tell(_translationLookup["COMMANDS_RUN_AS_FAIL_PERM"].FormatExt(gameEvent.Target.Name));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -53,11 +53,18 @@ namespace SharedLibraryCore.Commands
|
||||
gameEvent.Owner.Manager.AddEvent(impersonatedCommandEvent);
|
||||
|
||||
var result = await impersonatedCommandEvent.WaitAsync(Utilities.DefaultCommandTimeout, gameEvent.Owner.Manager.CancellationToken);
|
||||
await result.WaitAsync(Utilities.DefaultCommandTimeout, gameEvent.Owner.Manager.CancellationToken);
|
||||
|
||||
// remove the added command response
|
||||
foreach (var output in result.Output)
|
||||
// todo: something weird happening making this change required
|
||||
var responses = gameEvent.Owner.Manager.ProcessingEvents
|
||||
.Where(ev => ev.Value.CorrelationId == impersonatedCommandEvent.CorrelationId)
|
||||
.SelectMany(ev => ev.Value.Output)
|
||||
.ToList();
|
||||
|
||||
foreach (var output in responses)
|
||||
{
|
||||
gameEvent.Origin.Tell(_translationLookup["COMMANDS_RUN_AS_SUCCESS"].FormatExt(output));
|
||||
await gameEvent.Origin.Tell(_translationLookup["COMMANDS_RUN_AS_SUCCESS"].FormatExt(output)).WaitAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ namespace SharedLibraryCore.Database.Models
|
||||
using (LogContext.PushProperty("Server", CurrentServer?.ToString()))
|
||||
{
|
||||
Utilities.DefaultLogger.LogInformation("Client {client} is joining the game from {source}", ToString(), ipAddress.HasValue ? "Status" : "Log");
|
||||
|
||||
|
||||
if (ipAddress != null)
|
||||
{
|
||||
IPAddress = ipAddress;
|
||||
|
@ -44,7 +44,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.10" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="RaidMax.IW4MAdmin.Data" Version="1.0.3" />
|
||||
<PackageReference Include="RaidMax.IW4MAdmin.Data" Version="1.0.4" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
|
||||
<PackageReference Include="SimpleCrypto.NetCore" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
@ -1070,6 +1070,31 @@ namespace SharedLibraryCore
|
||||
return value?.ToNumericalString(precision);
|
||||
}
|
||||
|
||||
public static string[] FragmentMessageForDisplay(this string message)
|
||||
{
|
||||
var messages = new List<string>();
|
||||
var length = 48;
|
||||
|
||||
if (message.Length <= length)
|
||||
{
|
||||
return new[] {message};
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < message.Length - length; i += length)
|
||||
{
|
||||
messages.Add(new string(message.Skip(i).Take(length).ToArray()));
|
||||
}
|
||||
|
||||
var left = message.Length - length;
|
||||
|
||||
if (left > 0)
|
||||
{
|
||||
messages.Add(new string(message.Skip(i).Take(left).ToArray()));
|
||||
}
|
||||
|
||||
return messages.ToArray();
|
||||
}
|
||||
|
||||
public static string FindRuleForReason(this string reason, ApplicationConfiguration appConfig, Server server)
|
||||
{
|
||||
// allow for penalty presets
|
||||
|
Reference in New Issue
Block a user