mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
Move/add client getters to ScriptPluginExtensions
This commit is contained in:
@ -1,7 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Data.Models.Client;
|
||||||
using Data.Models.Client.Stats;
|
using Data.Models.Client.Stats;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SharedLibraryCore.Interfaces;
|
||||||
|
|
||||||
namespace IW4MAdmin.Application.Extensions;
|
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();
|
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);
|
public abstract Task<long> GetIdForServer(Server server = null);
|
||||||
|
|
||||||
|
[Obsolete("Use the ScriptPluginExtension helper")]
|
||||||
public EFClient GetClientByNumber(int clientNumber) =>
|
public EFClient GetClientByNumber(int clientNumber) =>
|
||||||
GetClientsAsList().FirstOrDefault(client => client.ClientNumber == clientNumber);
|
GetClientsAsList().FirstOrDefault(client => client.ClientNumber == clientNumber);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user