mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-07 21:58:06 -05:00
Move/add client getters to ScriptPluginExtensions
This commit is contained in:
parent
b003ba2b75
commit
e6272f610a
@ -1,7 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Data.Models.Client;
|
||||
using Data.Models.Client.Stats;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
|
||||
namespace IW4MAdmin.Application.Extensions;
|
||||
|
||||
@ -25,4 +27,16 @@ public static class ScriptPluginExtensions
|
||||
{
|
||||
return set.Where(stat => clientIds.Contains(stat.ClientId) && stat.ServerId == (long)serverId).ToList();
|
||||
}
|
||||
|
||||
public static EFClient GetClientByNumber(this IGameServer server, int clientNumber) =>
|
||||
server.ConnectedClients.FirstOrDefault(client => client.ClientNumber == clientNumber);
|
||||
|
||||
public static EFClient GetClientByGuid(this IGameServer server, string clientGuid) =>
|
||||
server.ConnectedClients.FirstOrDefault(client => client?.GuidString == clientGuid?.Trim().ToLower());
|
||||
|
||||
public static EFClient GetClientByXuid(this IGameServer server, string clientGuid) =>
|
||||
server.ConnectedClients.FirstOrDefault(client => client?.XuidString == clientGuid?.Trim().ToLower());
|
||||
|
||||
public static EFClient GetClientByDecimalGuid(this IGameServer server, string clientGuid) =>
|
||||
server.ConnectedClients.FirstOrDefault(client => client.NetworkId.ToString() == clientGuid?.Trim().ToLower());
|
||||
}
|
||||
|
@ -434,6 +434,7 @@ namespace SharedLibraryCore
|
||||
|
||||
public abstract Task<long> GetIdForServer(Server server = null);
|
||||
|
||||
[Obsolete("Use the ScriptPluginExtension helper")]
|
||||
public EFClient GetClientByNumber(int clientNumber) =>
|
||||
GetClientsAsList().FirstOrDefault(client => client.ClientNumber == clientNumber);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user