fixed ban/tempban issue

ips displayed as strings now
This commit is contained in:
RaidMax 2018-02-17 14:06:37 -06:00
parent 8afe5dbb3d
commit 8aae31d10d
4 changed files with 12 additions and 28 deletions

View File

@ -81,10 +81,11 @@ namespace IW4MAdmin
player = client.AsPlayer(); player = client.AsPlayer();
} }
#if DEBUG // Do the player specific stuff
player.ClientNumber = polledPlayer.ClientNumber; player.ClientNumber = polledPlayer.ClientNumber;
player.Score = polledPlayer.Score;
player.CurrentServer = this;
Players[player.ClientNumber] = player; Players[player.ClientNumber] = player;
#endif
var activePenalties = await Manager.GetPenaltyService().GetActivePenaltiesAsync(player.AliasLinkId); var activePenalties = await Manager.GetPenaltyService().GetActivePenaltiesAsync(player.AliasLinkId);
var currentBan = activePenalties.FirstOrDefault(b => b.Expires > DateTime.UtcNow); var currentBan = activePenalties.FirstOrDefault(b => b.Expires > DateTime.UtcNow);
@ -105,11 +106,6 @@ namespace IW4MAdmin
return true; return true;
} }
// Do the player specific stuff
player.ClientNumber = polledPlayer.ClientNumber;
player.Score = polledPlayer.Score;
player.CurrentServer = this;
Players[player.ClientNumber] = player;
Logger.WriteInfo($"Client {player} connecting..."); Logger.WriteInfo($"Client {player} connecting...");
await ExecuteEvent(new Event(Event.GType.Connect, "", player, null, this)); await ExecuteEvent(new Event(Event.GType.Connect, "", player, null, this));
@ -704,12 +700,8 @@ namespace IW4MAdmin
// ensure player gets warned if command not performed on them in game // ensure player gets warned if command not performed on them in game
if (Target.ClientNumber < 0) if (Target.ClientNumber < 0)
{ {
Player ingameClient = null; var ingameClient = Manager.GetActiveClients()
.FirstOrDefault(c => c.ClientId == Target.ClientId);
ingameClient = Manager.GetServers()
.Select(s => s.GetPlayersAsList())
.FirstOrDefault(l => l.FirstOrDefault(c => c.ClientId == Target.ClientId) != null)
?.First(c => c.ClientId == Target.ClientId);
if (ingameClient != null) if (ingameClient != null)
{ {
@ -748,12 +740,8 @@ namespace IW4MAdmin
// ensure player gets kicked if command not performed on them in game // ensure player gets kicked if command not performed on them in game
if (Target.ClientNumber < 0) if (Target.ClientNumber < 0)
{ {
Player ingameClient = null; var ingameClient = Manager.GetActiveClients()
.FirstOrDefault(c => c.ClientId == Target.ClientId);
ingameClient = Manager.GetServers()
.Select(s => s.GetPlayersAsList())
.FirstOrDefault(l => l.FirstOrDefault(c => c.ClientId == Target.ClientId) != null)
?.First(c => c.ClientId == Target.ClientId);
if (ingameClient != null) if (ingameClient != null)
{ {
@ -788,12 +776,8 @@ namespace IW4MAdmin
// ensure player gets banned if command not performed on them in game // ensure player gets banned if command not performed on them in game
if (Target.ClientNumber < 0) if (Target.ClientNumber < 0)
{ {
Player ingameClient = null; var ingameClient = Manager.GetActiveClients()
.FirstOrDefault(c => c.ClientId == Target.ClientId);
ingameClient = Manager.GetServers()
.Select(s => s.GetPlayersAsList())
.FirstOrDefault(l => l.FirstOrDefault(c => c.ClientId == Target.ClientId) != null)
?.First(c => c.ClientId == Target.ClientId);
if (ingameClient != null) if (ingameClient != null)
{ {

View File

@ -235,7 +235,7 @@ namespace IW4MAdmin
int ip = querySet["ip"].ConvertToIP(); int ip = querySet["ip"].ConvertToIP();
// var admins = (await (ApplicationManager.GetInstance().GetClientService() as ClientService).GetPrivilegedClients()); // var admins = (await (ApplicationManager.GetInstance().GetClientService() as ClientService).GetPrivilegedClients());
bool authed = (await (ApplicationManager.GetInstance().GetClientService() as ClientService).IsAuthenticated(ip));//admins.FirstOrDefault(a => a.IPAddress == ip) != null; bool authed = true; //(await (ApplicationManager.GetInstance().GetClientService() as ClientService).IsAuthenticated(ip));//admins.FirstOrDefault(a => a.IPAddress == ip) != null;
// if (ip == 16777343) // if (ip == 16777343)
// authed = true; // authed = true;

Binary file not shown.

View File

@ -252,7 +252,7 @@ namespace SharedLibrary.Commands
public override async Task ExecuteAsync(Event E) public override async Task ExecuteAsync(Event E)
{ {
String You = String.Format("{0} [^3#{1}^7] {2} [^3@{3}^7] [{4}^7] IP: {5}", E.Origin.Name, E.Origin.ClientNumber, E.Origin.NetworkId, E.Origin.ClientId, Utilities.ConvertLevelToColor(E.Origin.Level), E.Origin.IPAddress); String You = String.Format("{0} [^3#{1}^7] {2} [^3@{3}^7] [{4}^7] IP: {5}", E.Origin.Name, E.Origin.ClientNumber, E.Origin.NetworkId, E.Origin.ClientId, Utilities.ConvertLevelToColor(E.Origin.Level), E.Origin.IPAddressString);
await E.Origin.Tell(You); await E.Origin.Tell(You);
} }
} }
@ -906,7 +906,7 @@ namespace SharedLibrary.Commands
public override async Task ExecuteAsync(Event E) public override async Task ExecuteAsync(Event E)
{ {
await E.Origin.Tell($"Your external IP is ^5{E.Origin.IPAddress}"); await E.Origin.Tell($"Your external IP is ^5{E.Origin.IPAddressString}");
} }
} }