mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
fix stat issue with concurrent threads
fix potential lost penalty if server does not response to kick request make sure that broadcast only shows one custom say name add unit tests
This commit is contained in:
@ -124,6 +124,9 @@ namespace SharedLibraryCore.Database.Models
|
||||
[NotMapped]
|
||||
public string IPAddressString => IPAddress.ConvertIPtoString();
|
||||
|
||||
[NotMapped]
|
||||
public bool IsIngame => ClientNumber >= 0;
|
||||
|
||||
[NotMapped]
|
||||
public virtual IDictionary<int, long> LinkedAccounts { get; set; }
|
||||
|
||||
|
@ -121,8 +121,7 @@ namespace SharedLibraryCore
|
||||
/// <param name="message">Message to be sent to all players</param>
|
||||
public GameEvent Broadcast(string message, EFClient sender = null)
|
||||
{
|
||||
string formattedMessage = String.Format(RconParser.Configuration.CommandPrefixes.Say, $"{(CustomSayEnabled ? $"{CustomSayName}: " : "")}{message.FixIW4ForwardSlash()}");
|
||||
|
||||
string formattedMessage = string.Format(RconParser.Configuration.CommandPrefixes.Say, $"{(CustomSayEnabled && GameName == Game.IW4 ? $"{CustomSayName}: " : "")}{message.FixIW4ForwardSlash()}");
|
||||
#if DEBUG == true
|
||||
Logger.WriteVerbose(message.StripColors());
|
||||
#endif
|
||||
@ -196,14 +195,14 @@ namespace SharedLibraryCore
|
||||
/// </summary>
|
||||
/// <param name="Reason">Reason for kicking</param>
|
||||
/// <param name="Target">EFClient to kick</param>
|
||||
abstract protected Task Kick(String Reason, EFClient Target, EFClient Origin);
|
||||
abstract public Task Kick(String Reason, EFClient Target, EFClient Origin);
|
||||
|
||||
/// <summary>
|
||||
/// Temporarily ban a player ( default 1 hour ) from the server
|
||||
/// </summary>
|
||||
/// <param name="Reason">Reason for banning the player</param>
|
||||
/// <param name="Target">The player to ban</param>
|
||||
abstract protected Task TempBan(String Reason, TimeSpan length, EFClient Target, EFClient Origin);
|
||||
abstract public Task TempBan(String Reason, TimeSpan length, EFClient Target, EFClient Origin);
|
||||
|
||||
/// <summary>
|
||||
/// Perm ban a player from the server
|
||||
@ -211,9 +210,9 @@ namespace SharedLibraryCore
|
||||
/// <param name="Reason">The reason for the ban</param>
|
||||
/// <param name="Target">The person to ban</param>
|
||||
/// <param name="Origin">The person who banned the target</param>
|
||||
abstract protected Task Ban(String Reason, EFClient Target, EFClient Origin, bool isEvade = false);
|
||||
abstract public Task Ban(String Reason, EFClient Target, EFClient Origin, bool isEvade = false);
|
||||
|
||||
abstract protected Task Warn(String Reason, EFClient Target, EFClient Origin);
|
||||
abstract public Task Warn(String Reason, EFClient Target, EFClient Origin);
|
||||
|
||||
/// <summary>
|
||||
/// Unban a player by npID / GUID
|
||||
@ -307,7 +306,7 @@ namespace SharedLibraryCore
|
||||
public bool CustomCallback { get; protected set; }
|
||||
public string WorkingDirectory { get; protected set; }
|
||||
public IRConConnection RemoteConnection { get; protected set; }
|
||||
public IRConParser RconParser { get; protected set; }
|
||||
public IRConParser RconParser { get; set; }
|
||||
public IEventParser EventParser { get; set; }
|
||||
public string LogPath { get; protected set; }
|
||||
public bool RestartRequested { get; set; }
|
||||
|
@ -12,7 +12,7 @@ namespace SharedLibraryCore.Services
|
||||
{
|
||||
public class PenaltyService : Interfaces.IEntityService<EFPenalty>
|
||||
{
|
||||
public async Task<EFPenalty> Create(EFPenalty newEntity)
|
||||
public virtual async Task<EFPenalty> Create(EFPenalty newEntity)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
@ -181,7 +181,7 @@ namespace SharedLibraryCore.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RemoveActivePenalties(int aliasLinkId)
|
||||
public virtual async Task RemoveActivePenalties(int aliasLinkId)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
|
@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore.Storage;
|
||||
#endif
|
||||
using SharedLibraryCore.Database.Models;
|
||||
using SharedLibraryCore.Helpers;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@ -875,6 +876,30 @@ namespace SharedLibraryCore
|
||||
return new[] { deltaX, deltaY };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// attempts to create and persist a penalty
|
||||
/// </summary>
|
||||
/// <param name="penalty"></param>
|
||||
/// <param name="penaltyService"></param>
|
||||
/// <param name="logger"></param>
|
||||
/// <returns>true of the creat succeeds, false otherwise</returns>
|
||||
public static async Task<bool> TryCreatePenalty(this EFPenalty penalty, IEntityService<EFPenalty> penaltyService, ILogger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
await penaltyService.Create(penalty);
|
||||
return true;
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.WriteWarning($"Could not create penalty of type {penalty.Type.ToString()}");
|
||||
logger.WriteDebug(e.GetExceptionInfo());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool ShouldHideLevel(this Permission perm) => perm == Permission.Flagged;
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user