combined Penalty and EFPenalty

moved some classes around
This commit is contained in:
RaidMax 2019-05-29 16:55:35 -05:00
parent 0b0290a871
commit 95d64df321
54 changed files with 231 additions and 207 deletions

View File

@ -6,7 +6,7 @@
<RuntimeFrameworkVersion>2.2.2</RuntimeFrameworkVersion> <RuntimeFrameworkVersion>2.2.2</RuntimeFrameworkVersion>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish> <MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
<PackageId>RaidMax.IW4MAdmin.Application</PackageId> <PackageId>RaidMax.IW4MAdmin.Application</PackageId>
<Version>2.2.7.3</Version> <Version>2.2.7.4</Version>
<Authors>RaidMax</Authors> <Authors>RaidMax</Authors>
<Company>Forever None</Company> <Company>Forever None</Company>
<Product>IW4MAdmin</Product> <Product>IW4MAdmin</Product>
@ -32,8 +32,8 @@
<PropertyGroup> <PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection> <ServerGarbageCollection>true</ServerGarbageCollection>
<TieredCompilation>true</TieredCompilation> <TieredCompilation>true</TieredCompilation>
<AssemblyVersion>2.2.7.3</AssemblyVersion> <AssemblyVersion>2.2.7.4</AssemblyVersion>
<FileVersion>2.2.7.3</FileVersion> <FileVersion>2.2.7.4</FileVersion>
<LangVersion>7.1</LangVersion> <LangVersion>7.1</LangVersion>
</PropertyGroup> </PropertyGroup>

View File

@ -12,7 +12,6 @@ using SharedLibraryCore.Events;
using SharedLibraryCore.Exceptions; using SharedLibraryCore.Exceptions;
using SharedLibraryCore.Helpers; using SharedLibraryCore.Helpers;
using SharedLibraryCore.Interfaces; using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Services; using SharedLibraryCore.Services;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;

View File

@ -104,7 +104,8 @@ namespace IW4MAdmin.Application.EventParsers
Type = GameEvent.EventType.Command, Type = GameEvent.EventType.Command,
Data = message, Data = message,
Origin = new EFClient() { NetworkId = originId }, Origin = new EFClient() { NetworkId = originId },
Message = message Message = message,
RequiredEntity = GameEvent.EventRequiredEntity.Origin
}; };
} }
@ -113,7 +114,8 @@ namespace IW4MAdmin.Application.EventParsers
Type = GameEvent.EventType.Say, Type = GameEvent.EventType.Say,
Data = message, Data = message,
Origin = new EFClient() { NetworkId = originId }, Origin = new EFClient() { NetworkId = originId },
Message = message Message = message,
RequiredEntity = GameEvent.EventRequiredEntity.Origin
}; };
} }
} }
@ -121,13 +123,12 @@ namespace IW4MAdmin.Application.EventParsers
if (eventType == "K") if (eventType == "K")
{ {
var match = Regex.Match(logLine, Configuration.Kill.Pattern); var match = Regex.Match(logLine, Configuration.Kill.Pattern);
if (match.Success) if (match.Success)
{ {
long originId = match.Groups[Configuration.Kill.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].Value.ToString().ConvertGuidToLong(1); long originId = match.Groups[Configuration.Kill.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].Value.ToString().ConvertGuidToLong(1);
long targetId = match.Groups[Configuration.Kill.GroupMapping[ParserRegex.GroupType.TargetNetworkId]].Value.ToString().ConvertGuidToLong(); long targetId = match.Groups[Configuration.Kill.GroupMapping[ParserRegex.GroupType.TargetNetworkId]].Value.ToString().ConvertGuidToLong(1);
return new GameEvent() return new GameEvent()
{ {
@ -135,27 +136,29 @@ namespace IW4MAdmin.Application.EventParsers
Data = logLine, Data = logLine,
Origin = new EFClient() { NetworkId = originId }, Origin = new EFClient() { NetworkId = originId },
Target = new EFClient() { NetworkId = targetId }, Target = new EFClient() { NetworkId = targetId },
RequiredEntity = GameEvent.EventRequiredEntity.Origin | GameEvent.EventRequiredEntity.Target
}; };
} }
} }
if (eventType == "D") if (eventType == "D")
{ {
var regexMatch = Regex.Match(logLine, Configuration.Damage.Pattern); var regexMatch = Regex.Match(logLine, Configuration.Damage.Pattern);
if (regexMatch.Success) if (regexMatch.Success)
{
long originId = regexMatch.Groups[Configuration.Damage.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(1);
long targetId = regexMatch.Groups[Configuration.Damage.GroupMapping[ParserRegex.GroupType.TargetNetworkId]].ToString().ConvertGuidToLong(1);
return new GameEvent()
{ {
long originId = regexMatch.Groups[Configuration.Damage.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(1); Type = GameEvent.EventType.Damage,
long targetId = regexMatch.Groups[Configuration.Damage.GroupMapping[ParserRegex.GroupType.TargetNetworkId]].ToString().ConvertGuidToLong(); Data = logLine,
Origin = new EFClient() { NetworkId = originId },
return new GameEvent() Target = new EFClient() { NetworkId = targetId },
{ RequiredEntity = GameEvent.EventRequiredEntity.Origin | GameEvent.EventRequiredEntity.Target
Type = GameEvent.EventType.Damage, };
Data = logLine, }
Origin = new EFClient() { NetworkId = originId },
Target = new EFClient() { NetworkId = targetId }
};
}
} }
if (eventType == "J") if (eventType == "J")
@ -177,7 +180,8 @@ namespace IW4MAdmin.Application.EventParsers
NetworkId = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(), NetworkId = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(),
ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()), ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()),
State = EFClient.ClientState.Connecting, State = EFClient.ClientState.Connecting,
} },
RequiredEntity = GameEvent.EventRequiredEntity.None
}; };
} }
} }
@ -200,7 +204,8 @@ namespace IW4MAdmin.Application.EventParsers
NetworkId = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(), NetworkId = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(),
ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()), ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()),
State = EFClient.ClientState.Disconnecting State = EFClient.ClientState.Disconnecting
} },
RequiredEntity = GameEvent.EventRequiredEntity.Origin
}; };
} }
} }
@ -213,6 +218,7 @@ namespace IW4MAdmin.Application.EventParsers
Data = lineSplit[0], Data = lineSplit[0],
Origin = Utilities.IW4MAdminClient(), Origin = Utilities.IW4MAdminClient(),
Target = Utilities.IW4MAdminClient(), Target = Utilities.IW4MAdminClient(),
RequiredEntity = GameEvent.EventRequiredEntity.None
}; };
} }
@ -226,7 +232,8 @@ namespace IW4MAdmin.Application.EventParsers
Data = lineSplit[0], Data = lineSplit[0],
Origin = Utilities.IW4MAdminClient(), Origin = Utilities.IW4MAdminClient(),
Target = Utilities.IW4MAdminClient(), Target = Utilities.IW4MAdminClient(),
Extra = dump.DictionaryFromKeyValue() Extra = dump.DictionaryFromKeyValue(),
RequiredEntity = GameEvent.EventRequiredEntity.None
}; };
} }
@ -237,7 +244,8 @@ namespace IW4MAdmin.Application.EventParsers
{ {
Type = GameEvent.EventType.JoinTeam, Type = GameEvent.EventType.JoinTeam,
Data = logLine, Data = logLine,
Origin = new EFClient() { NetworkId = lineSplit[1].ConvertGuidToLong() } Origin = new EFClient() { NetworkId = lineSplit[1].ConvertGuidToLong() },
RequiredEntity = GameEvent.EventRequiredEntity.Target
}; };
} }
@ -245,14 +253,15 @@ namespace IW4MAdmin.Application.EventParsers
if (eventType == "ScriptKill") if (eventType == "ScriptKill")
{ {
long originId = lineSplit[1].ConvertGuidToLong(1); long originId = lineSplit[1].ConvertGuidToLong(1);
long targetId = lineSplit[2].ConvertGuidToLong(); long targetId = lineSplit[2].ConvertGuidToLong(1);
return new GameEvent() return new GameEvent()
{ {
Type = GameEvent.EventType.ScriptKill, Type = GameEvent.EventType.ScriptKill,
Data = logLine, Data = logLine,
Origin = new EFClient() { NetworkId = originId }, Origin = new EFClient() { NetworkId = originId },
Target = new EFClient() { NetworkId = targetId } Target = new EFClient() { NetworkId = targetId },
RequiredEntity = GameEvent.EventRequiredEntity.Origin | GameEvent.EventRequiredEntity.Target
}; };
} }
@ -260,14 +269,15 @@ namespace IW4MAdmin.Application.EventParsers
if (eventType == "ScriptDamage") if (eventType == "ScriptDamage")
{ {
long originId = lineSplit[1].ConvertGuidToLong(1); long originId = lineSplit[1].ConvertGuidToLong(1);
long targetId = lineSplit[2].ConvertGuidToLong(); long targetId = lineSplit[2].ConvertGuidToLong(1);
return new GameEvent() return new GameEvent()
{ {
Type = GameEvent.EventType.ScriptDamage, Type = GameEvent.EventType.ScriptDamage,
Data = logLine, Data = logLine,
Origin = new EFClient() { NetworkId = originId }, Origin = new EFClient() { NetworkId = originId },
Target = new EFClient() { NetworkId = targetId } Target = new EFClient() { NetworkId = targetId },
RequiredEntity = GameEvent.EventRequiredEntity.Origin | GameEvent.EventRequiredEntity.Target
}; };
} }
@ -275,7 +285,8 @@ namespace IW4MAdmin.Application.EventParsers
{ {
Type = GameEvent.EventType.Unknown, Type = GameEvent.EventType.Unknown,
Origin = Utilities.IW4MAdminClient(), Origin = Utilities.IW4MAdminClient(),
Target = Utilities.IW4MAdminClient() Target = Utilities.IW4MAdminClient(),
RequiredEntity = GameEvent.EventRequiredEntity.None
}; };
} }
} }

View File

@ -61,9 +61,26 @@ namespace IW4MAdmin.Application.IO
if (!ignoreBots.Value || (ignoreBots.Value && !((gameEvent.Origin?.IsBot ?? false) || (gameEvent.Target?.IsBot ?? false)))) if (!ignoreBots.Value || (ignoreBots.Value && !((gameEvent.Origin?.IsBot ?? false) || (gameEvent.Target?.IsBot ?? false))))
{ {
gameEvent.Owner = server; gameEvent.Owner = server;
// we need to pull the "live" versions of the client (only if the client id isn't IW4MAdmin)
gameEvent.Origin = gameEvent.Origin == null || gameEvent.Origin.NetworkId == 1 ? gameEvent.Origin : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Origin.NetworkId); if ((gameEvent.RequiredEntity & GameEvent.EventRequiredEntity.Origin) == GameEvent.EventRequiredEntity.Origin && gameEvent.Origin.NetworkId != 1)
gameEvent.Target = gameEvent.Target == null || gameEvent.Target.NetworkId == 1 ? gameEvent.Target : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Target.NetworkId); {
gameEvent.Origin = server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Origin?.NetworkId);
}
if ((gameEvent.RequiredEntity & GameEvent.EventRequiredEntity.Target) == GameEvent.EventRequiredEntity.Target)
{
gameEvent.Target = server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Target?.NetworkId);
}
if (gameEvent.Origin != null)
{
gameEvent.Origin.CurrentServer = server;
}
if (gameEvent.Target != null)
{
gameEvent.Target.CurrentServer = server;
}
events.Add(gameEvent); events.Add(gameEvent);
} }

View File

@ -65,9 +65,26 @@ namespace IW4MAdmin.Application.IO
if (!ignoreBots.Value || (ignoreBots.Value && !((gameEvent.Origin?.IsBot ?? false) || (gameEvent.Target?.IsBot ?? false)))) if (!ignoreBots.Value || (ignoreBots.Value && !((gameEvent.Origin?.IsBot ?? false) || (gameEvent.Target?.IsBot ?? false))))
{ {
gameEvent.Owner = server; gameEvent.Owner = server;
// we need to pull the "live" versions of the client (only if the client id isn't IW4MAdmin)
gameEvent.Origin = gameEvent.Origin == null || gameEvent.Origin.NetworkId == 1 ? gameEvent.Origin : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Origin.NetworkId); if ((gameEvent.RequiredEntity & GameEvent.EventRequiredEntity.Origin) == GameEvent.EventRequiredEntity.Origin && gameEvent.Origin.NetworkId != 1)
gameEvent.Target = gameEvent.Target == null || gameEvent.Target.NetworkId == 1 ? gameEvent.Target : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Target.NetworkId); {
gameEvent.Origin = server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Origin?.NetworkId);
}
if ((gameEvent.RequiredEntity & GameEvent.EventRequiredEntity.Target) == GameEvent.EventRequiredEntity.Target)
{
gameEvent.Target = server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Target?.NetworkId);
}
if (gameEvent.Origin != null)
{
gameEvent.Origin.CurrentServer = server;
}
if (gameEvent.Target != null)
{
gameEvent.Target.CurrentServer = server;
}
events.Add(gameEvent); events.Add(gameEvent);
} }

View File

@ -6,9 +6,9 @@ using SharedLibraryCore.Configuration;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Dtos; using SharedLibraryCore.Dtos;
using SharedLibraryCore.Exceptions; using SharedLibraryCore.Exceptions;
using SharedLibraryCore.Helpers;
using SharedLibraryCore.Interfaces; using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Localization; using SharedLibraryCore.Localization;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Services; using SharedLibraryCore.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -74,9 +74,9 @@ namespace IW4MAdmin
Type = GameEvent.EventType.Connect Type = GameEvent.EventType.Connect
}; };
Manager.GetEventHandler().AddEvent(e);
await client.OnJoin(client.IPAddress); await client.OnJoin(client.IPAddress);
client.State = ClientState.Connected; client.State = ClientState.Connected;
Manager.GetEventHandler().AddEvent(e);
} }
override public async Task OnClientDisconnected(EFClient client) override public async Task OnClientDisconnected(EFClient client)
@ -249,7 +249,7 @@ namespace IW4MAdmin
// for some reason there's still a client in the spot // for some reason there's still a client in the spot
else else
{ {
Logger.WriteWarning($"{E.Origin} is connecteding but {Clients[E.Origin.ClientNumber]} is currently in that client slot"); Logger.WriteWarning($"{E.Origin} is connecting but {Clients[E.Origin.ClientNumber]} is currently in that client slot");
await OnClientDisconnected(Clients[E.Origin.ClientNumber]); await OnClientDisconnected(Clients[E.Origin.ClientNumber]);
goto CONNECT; goto CONNECT;
} }
@ -258,9 +258,9 @@ namespace IW4MAdmin
else if (E.Type == GameEvent.EventType.Flag) else if (E.Type == GameEvent.EventType.Flag)
{ {
// todo: maybe move this to a seperate function // todo: maybe move this to a seperate function
Penalty newPenalty = new Penalty() var newPenalty = new EFPenalty()
{ {
Type = Penalty.PenaltyType.Flag, Type = EFPenalty.PenaltyType.Flag,
Expires = DateTime.UtcNow, Expires = DateTime.UtcNow,
Offender = E.Target, Offender = E.Target,
Offense = E.Data, Offense = E.Data,
@ -275,9 +275,9 @@ namespace IW4MAdmin
else if (E.Type == GameEvent.EventType.Unflag) else if (E.Type == GameEvent.EventType.Unflag)
{ {
var unflagPenalty = new Penalty() var unflagPenalty = new EFPenalty()
{ {
Type = Penalty.PenaltyType.Unflag, Type = EFPenalty.PenaltyType.Unflag,
Expires = DateTime.UtcNow, Expires = DateTime.UtcNow,
Offender = E.Target, Offender = E.Target,
Offense = E.Data, Offense = E.Data,
@ -299,9 +299,9 @@ namespace IW4MAdmin
Reason = E.Data Reason = E.Data
}); });
Penalty newReport = new Penalty() var newReport = new EFPenalty()
{ {
Type = Penalty.PenaltyType.Report, Type = EFPenalty.PenaltyType.Report,
Expires = DateTime.UtcNow, Expires = DateTime.UtcNow,
Offender = E.Target, Offender = E.Target,
Offense = E.Message, Offense = E.Message,
@ -620,7 +620,7 @@ namespace IW4MAdmin
foreach (var client in polledClients[0]) foreach (var client in polledClients[0])
{ {
// note: this prevents players in ZMBI state from being registered with no name // note: this prevents players in ZMBI state from being registered with no name
if (string.IsNullOrEmpty(client.Name)) if (string.IsNullOrEmpty(client.Name) || client.Ping == 999)
{ {
continue; continue;
} }
@ -898,9 +898,9 @@ namespace IW4MAdmin
Target.CurrentServer.Broadcast(message); Target.CurrentServer.Broadcast(message);
} }
Penalty newPenalty = new Penalty() var newPenalty = new EFPenalty()
{ {
Type = Penalty.PenaltyType.Warning, Type = EFPenalty.PenaltyType.Warning,
Expires = DateTime.UtcNow, Expires = DateTime.UtcNow,
Offender = Target, Offender = Target,
Punisher = Origin, Punisher = Origin,
@ -937,9 +937,9 @@ namespace IW4MAdmin
await Target.CurrentServer.OnClientDisconnected(Target); await Target.CurrentServer.OnClientDisconnected(Target);
#endif #endif
var newPenalty = new Penalty() var newPenalty = new EFPenalty()
{ {
Type = Penalty.PenaltyType.Kick, Type = EFPenalty.PenaltyType.Kick,
Expires = DateTime.UtcNow, Expires = DateTime.UtcNow,
Offender = Target, Offender = Target,
Offense = Reason, Offense = Reason,
@ -974,9 +974,9 @@ namespace IW4MAdmin
await Target.CurrentServer.OnClientDisconnected(Target); await Target.CurrentServer.OnClientDisconnected(Target);
#endif #endif
Penalty newPenalty = new Penalty() var newPenalty = new EFPenalty()
{ {
Type = Penalty.PenaltyType.TempBan, Type = EFPenalty.PenaltyType.TempBan,
Expires = DateTime.UtcNow + length, Expires = DateTime.UtcNow + length,
Offender = Target, Offender = Target,
Offense = Reason, Offense = Reason,
@ -1008,7 +1008,6 @@ namespace IW4MAdmin
else else
{ {
#if !DEBUG #if !DEBUG
string formattedString = String.Format(RconParser.Configuration.CommandPrefixes.Kick, targetClient.ClientNumber, $"{loc["SERVER_BAN_TEXT"]} - ^5{reason} ^7{loc["SERVER_BAN_APPEAL"].FormatExt(Website)}^7"); string formattedString = String.Format(RconParser.Configuration.CommandPrefixes.Kick, targetClient.ClientNumber, $"{loc["SERVER_BAN_TEXT"]} - ^5{reason} ^7{loc["SERVER_BAN_APPEAL"].FormatExt(Website)}^7");
await targetClient.CurrentServer.ExecuteCommandAsync(formattedString); await targetClient.CurrentServer.ExecuteCommandAsync(formattedString);
@ -1017,9 +1016,9 @@ namespace IW4MAdmin
#endif #endif
} }
Penalty newPenalty = new Penalty() EFPenalty newPenalty = new EFPenalty()
{ {
Type = Penalty.PenaltyType.Ban, Type = EFPenalty.PenaltyType.Ban,
Expires = null, Expires = null,
Offender = targetClient, Offender = targetClient,
Offense = reason, Offense = reason,
@ -1027,7 +1026,6 @@ namespace IW4MAdmin
Link = targetClient.AliasLink, Link = targetClient.AliasLink,
AutomatedOffense = originClient.AdministeredPenalties?.FirstOrDefault()?.AutomatedOffense, AutomatedOffense = originClient.AdministeredPenalties?.FirstOrDefault()?.AutomatedOffense,
IsEvadedOffense = isEvade IsEvadedOffense = isEvade
}; };
targetClient.SetLevel(Permission.Banned, originClient); targetClient.SetLevel(Permission.Banned, originClient);
@ -1036,9 +1034,9 @@ namespace IW4MAdmin
override public async Task Unban(string reason, EFClient Target, EFClient Origin) override public async Task Unban(string reason, EFClient Target, EFClient Origin)
{ {
var unbanPenalty = new Penalty() var unbanPenalty = new EFPenalty()
{ {
Type = Penalty.PenaltyType.Unban, Type = EFPenalty.PenaltyType.Unban,
Expires = null, Expires = null,
Offender = Target, Offender = Target,
Offense = reason, Offense = reason,

View File

@ -148,11 +148,11 @@ namespace IW4MAdmin.Application.RconParsers
{ {
CurrentAlias = new EFAlias() CurrentAlias = new EFAlias()
{ {
Name = name Name = name,
IPAddress = ip
}, },
NetworkId = networkId, NetworkId = networkId,
ClientNumber = clientNumber, ClientNumber = clientNumber,
IPAddress = ip,
Ping = ping, Ping = ping,
Score = score, Score = score,
State = EFClient.ClientState.Connecting State = EFClient.ClientState.Connecting

View File

@ -1,6 +1,5 @@
using SharedLibraryCore; using SharedLibraryCore;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Objects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,7 +1,6 @@
using IW4ScriptCommands.Commands; using IW4ScriptCommands.Commands;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore; using SharedLibraryCore;
using SharedLibraryCore.Objects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,6 +1,6 @@
var plugin = { var plugin = {
author: 'RaidMax', author: 'RaidMax',
version: 1.1, version: 1.2,
name: 'VPN Detection Plugin', name: 'VPN Detection Plugin',
manager: null, manager: null,
@ -43,8 +43,8 @@ var plugin = {
}, },
onEventAsync: function (gameEvent, server) { onEventAsync: function (gameEvent, server) {
// connect event // join event
if (gameEvent.Type === 3) { if (gameEvent.Type === 4) {
this.checkForVpn(gameEvent.Origin); this.checkForVpn(gameEvent.Origin);
} }
}, },

View File

@ -1,7 +1,7 @@
using IW4MAdmin.Plugins.Stats.Models; using IW4MAdmin.Plugins.Stats.Models;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Helpers; using SharedLibraryCore.Helpers;
using SharedLibraryCore.Interfaces; using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Objects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -65,7 +65,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
{ {
return new DetectionPenaltyResult() return new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Any, ClientPenalty = EFPenalty.PenaltyType.Any,
}; };
} }
@ -104,7 +104,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
result = new DetectionPenaltyResult() result = new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Ban, ClientPenalty = EFPenalty.PenaltyType.Ban,
Value = hitLoc.HitOffsetAverage, Value = hitLoc.HitOffsetAverage,
HitCount = hitLoc.HitCount, HitCount = hitLoc.HitCount,
Type = DetectionType.Offset Type = DetectionType.Offset
@ -125,7 +125,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
result = new DetectionPenaltyResult() result = new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Ban, ClientPenalty = EFPenalty.PenaltyType.Ban,
Value = sessAverage, Value = sessAverage,
HitCount = HitCount, HitCount = HitCount,
Type = DetectionType.Offset, Type = DetectionType.Offset,
@ -154,7 +154,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
{ {
result = new DetectionPenaltyResult() result = new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Flag, ClientPenalty = EFPenalty.PenaltyType.Flag,
Value = currentStrain, Value = currentStrain,
HitCount = HitCount, HitCount = HitCount,
Type = DetectionType.Strain Type = DetectionType.Strain
@ -167,7 +167,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
{ {
result = new DetectionPenaltyResult() result = new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Ban, ClientPenalty = EFPenalty.PenaltyType.Ban,
Value = currentStrain, Value = currentStrain,
HitCount = HitCount, HitCount = HitCount,
Type = DetectionType.Strain Type = DetectionType.Strain
@ -216,7 +216,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
result = new DetectionPenaltyResult() result = new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Ban, ClientPenalty = EFPenalty.PenaltyType.Ban,
Value = currentHeadshotRatio, Value = currentHeadshotRatio,
Location = IW4Info.HitLocation.head, Location = IW4Info.HitLocation.head,
HitCount = HitCount, HitCount = HitCount,
@ -240,7 +240,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
result = new DetectionPenaltyResult() result = new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Flag, ClientPenalty = EFPenalty.PenaltyType.Flag,
Value = currentHeadshotRatio, Value = currentHeadshotRatio,
Location = IW4Info.HitLocation.head, Location = IW4Info.HitLocation.head,
HitCount = HitCount, HitCount = HitCount,
@ -272,7 +272,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
result = new DetectionPenaltyResult() result = new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Ban, ClientPenalty = EFPenalty.PenaltyType.Ban,
Value = currentMaxBoneRatio, Value = currentMaxBoneRatio,
Location = bone, Location = bone,
HitCount = HitCount, HitCount = HitCount,
@ -296,7 +296,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
result = new DetectionPenaltyResult() result = new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Flag, ClientPenalty = EFPenalty.PenaltyType.Flag,
Value = currentMaxBoneRatio, Value = currentMaxBoneRatio,
Location = bone, Location = bone,
HitCount = HitCount, HitCount = HitCount,
@ -337,7 +337,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
result = new DetectionPenaltyResult() result = new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Ban, ClientPenalty = EFPenalty.PenaltyType.Ban,
Value = currentChestAbdomenRatio, Value = currentChestAbdomenRatio,
Location = IW4Info.HitLocation.torso_upper, Location = IW4Info.HitLocation.torso_upper,
Type = DetectionType.Chest, Type = DetectionType.Chest,
@ -358,7 +358,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
result = new DetectionPenaltyResult() result = new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Flag, ClientPenalty = EFPenalty.PenaltyType.Flag,
Value = currentChestAbdomenRatio, Value = currentChestAbdomenRatio,
Location = IW4Info.HitLocation.torso_upper, Location = IW4Info.HitLocation.torso_upper,
Type = DetectionType.Chest, Type = DetectionType.Chest,
@ -401,7 +401,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
return result ?? new DetectionPenaltyResult() return result ?? new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Any, ClientPenalty = EFPenalty.PenaltyType.Any,
}; };
} }
@ -437,7 +437,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
return new DetectionPenaltyResult() return new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Ban, ClientPenalty = EFPenalty.PenaltyType.Ban,
Value = currentChestAbdomenRatio, Value = currentChestAbdomenRatio,
Location = IW4Info.HitLocation.torso_upper, Location = IW4Info.HitLocation.torso_upper,
HitCount = totalChestHits, HitCount = totalChestHits,
@ -458,7 +458,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
return new DetectionPenaltyResult() return new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Flag, ClientPenalty = EFPenalty.PenaltyType.Flag,
Value = currentChestAbdomenRatio, Value = currentChestAbdomenRatio,
Location = IW4Info.HitLocation.torso_upper, Location = IW4Info.HitLocation.torso_upper,
HitCount = totalChestHits, HitCount = totalChestHits,
@ -470,7 +470,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
return new DetectionPenaltyResult() return new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Any ClientPenalty = EFPenalty.PenaltyType.Any
}; };
} }
} }

View File

@ -1,11 +1,11 @@
using SharedLibraryCore.Objects; using SharedLibraryCore.Database.Models;
namespace IW4MAdmin.Plugins.Stats.Cheat namespace IW4MAdmin.Plugins.Stats.Cheat
{ {
class DetectionPenaltyResult class DetectionPenaltyResult
{ {
public Detection.DetectionType Type { get; set; } public Detection.DetectionType Type { get; set; }
public Penalty.PenaltyType ClientPenalty { get; set; } public EFPenalty.PenaltyType ClientPenalty { get; set; }
public double Value { get; set; } public double Value { get; set; }
public IW4Info.HitLocation Location { get; set; } public IW4Info.HitLocation Location { get; set; }
public int HitCount { get; set; } public int HitCount { get; set; }

View File

@ -4,7 +4,6 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using SharedLibraryCore; using SharedLibraryCore;
using SharedLibraryCore.Objects;
using IW4MAdmin.Plugins.Stats.Models; using IW4MAdmin.Plugins.Stats.Models;
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -4,7 +4,6 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using SharedLibraryCore; using SharedLibraryCore;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Services; using SharedLibraryCore.Services;
using IW4MAdmin.Plugins.Stats.Models; using IW4MAdmin.Plugins.Stats.Models;
using SharedLibraryCore.Database; using SharedLibraryCore.Database;

View File

@ -1,5 +1,4 @@
using SharedLibraryCore; using SharedLibraryCore;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Services; using SharedLibraryCore.Services;
using IW4MAdmin.Plugins.Stats.Models; using IW4MAdmin.Plugins.Stats.Models;
using System; using System;

View File

@ -7,7 +7,6 @@ using SharedLibraryCore.Database;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Helpers; using SharedLibraryCore.Helpers;
using SharedLibraryCore.Interfaces; using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Objects;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@ -614,7 +613,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
var penaltyClient = Utilities.IW4MAdminClient(attacker.CurrentServer); var penaltyClient = Utilities.IW4MAdminClient(attacker.CurrentServer);
switch (penalty.ClientPenalty) switch (penalty.ClientPenalty)
{ {
case Penalty.PenaltyType.Ban: case EFPenalty.PenaltyType.Ban:
if (attacker.Level == EFClient.Permission.Banned) if (attacker.Level == EFClient.Permission.Banned)
{ {
break; break;
@ -632,7 +631,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
await attacker.Ban(Utilities.CurrentLocalization.LocalizationIndex["PLUGIN_STATS_CHEAT_DETECTED"], penaltyClient, false).WaitAsync(Utilities.DefaultCommandTimeout, attacker.CurrentServer.Manager.CancellationToken); await attacker.Ban(Utilities.CurrentLocalization.LocalizationIndex["PLUGIN_STATS_CHEAT_DETECTED"], penaltyClient, false).WaitAsync(Utilities.DefaultCommandTimeout, attacker.CurrentServer.Manager.CancellationToken);
break; break;
case Penalty.PenaltyType.Flag: case EFPenalty.PenaltyType.Flag:
if (attacker.Level != EFClient.Permission.User) if (attacker.Level != EFClient.Permission.User)
{ {
break; break;
@ -1231,6 +1230,11 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
public static async Task<long> GetIdForServer(Server server) public static async Task<long> GetIdForServer(Server server)
{ {
if ($"{server.IP}:{server.GetPort().ToString()}" == "66.150.121.184:28965")
{
return 886229536;
}
long id = HashCode.Combine(server.IP, server.GetPort()); long id = HashCode.Combine(server.IP, server.GetPort());
id = id < 0 ? Math.Abs(id) : id; id = id < 0 ? Math.Abs(id) : id;
long? serverId; long? serverId;

View File

@ -80,7 +80,7 @@ namespace IW4MAdmin.Plugins.Stats
if (killInfo.Length >= 14 && !ShouldIgnoreEvent(E.Origin, E.Target)) if (killInfo.Length >= 14 && !ShouldIgnoreEvent(E.Origin, E.Target))
{ {
// this treats "world" damage as self damage // this treats "world" damage as self damage
if (E.Origin.ClientId == 1) if (IsWorldDamage(E.Origin))
{ {
E.Origin = E.Target; E.Origin = E.Target;
} }
@ -93,7 +93,7 @@ namespace IW4MAdmin.Plugins.Stats
if (!E.Owner.CustomCallback && !ShouldIgnoreEvent(E.Origin, E.Target)) if (!E.Owner.CustomCallback && !ShouldIgnoreEvent(E.Origin, E.Target))
{ {
// this treats "world" damage as self damage // this treats "world" damage as self damage
if (E.Origin.ClientId == 1) if (IsWorldDamage(E.Origin))
{ {
E.Origin = E.Target; E.Origin = E.Target;
} }
@ -105,7 +105,7 @@ namespace IW4MAdmin.Plugins.Stats
if (!E.Owner.CustomCallback && !ShouldIgnoreEvent(E.Origin, E.Target)) if (!E.Owner.CustomCallback && !ShouldIgnoreEvent(E.Origin, E.Target))
{ {
// this treats "world" damage as self damage // this treats "world" damage as self damage
if (E.Origin.ClientId == 1) if (IsWorldDamage(E.Origin))
{ {
E.Origin = E.Target; E.Origin = E.Target;
} }
@ -118,7 +118,7 @@ namespace IW4MAdmin.Plugins.Stats
if (killInfo.Length >= 14 && !ShouldIgnoreEvent(E.Origin, E.Target)) if (killInfo.Length >= 14 && !ShouldIgnoreEvent(E.Origin, E.Target))
{ {
// this treats "world" damage as self damage // this treats "world" damage as self damage
if (E.Origin.ClientId == 1) if (IsWorldDamage(E.Origin))
{ {
E.Origin = E.Target; E.Origin = E.Target;
} }
@ -471,7 +471,14 @@ namespace IW4MAdmin.Plugins.Stats
/// <returns></returns> /// <returns></returns>
private bool ShouldIgnoreEvent(EFClient origin, EFClient target) private bool ShouldIgnoreEvent(EFClient origin, EFClient target)
{ {
return (origin.ClientId <= 1 && target.ClientId <= 1); return ((origin?.NetworkId <= 1 && target?.NetworkId <= 1) || (origin?.ClientId <=1 && target?.ClientId <= 1));
} }
/// <summary>
/// Indicates if the damage occurs from world (fall damage/certain killstreaks)
/// </summary>
/// <param name="origin"></param>
/// <returns></returns>
private bool IsWorldDamage(EFClient origin) => origin?.NetworkId == 1;
} }
} }

View File

@ -2,7 +2,6 @@
using SharedLibraryCore; using SharedLibraryCore;
using SharedLibraryCore.Commands; using SharedLibraryCore.Commands;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Objects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -218,7 +217,7 @@ namespace Tests
Owner = client.CurrentServer Owner = client.CurrentServer
}).Wait(); }).Wait();
Assert.True(Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId).Result.Count(p => p.Type == Penalty.PenaltyType.TempBan) == 1, Assert.True(Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId).Result.Count(p => p.Type == EFPenalty.PenaltyType.TempBan) == 1,
"tempban was not added"); "tempban was not added");
} }
@ -243,7 +242,7 @@ namespace Tests
Owner = client.CurrentServer Owner = client.CurrentServer
}).Wait(); }).Wait();
Assert.True(Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId).Result.Count(p => p.Type == Penalty.PenaltyType.Ban) == 1, Assert.True(Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId).Result.Count(p => p.Type == EFPenalty.PenaltyType.Ban) == 1,
"ban was not added"); "ban was not added");
var unbanCommand = new CUnban(); var unbanCommand = new CUnban();
@ -256,7 +255,7 @@ namespace Tests
Owner = client.CurrentServer Owner = client.CurrentServer
}).Wait(); }).Wait();
Assert.True(Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId).Result.Count(p => p.Type == Penalty.PenaltyType.Ban) == 0, Assert.True(Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId).Result.Count(p => p.Type == EFPenalty.PenaltyType.Ban) == 0,
"ban was not removed"); "ban was not removed");
} }

View File

@ -2,7 +2,6 @@
using SharedLibraryCore; using SharedLibraryCore;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Interfaces; using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Objects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;

View File

@ -1,7 +1,6 @@
using IW4MAdmin.Application; using IW4MAdmin.Application;
using SharedLibraryCore; using SharedLibraryCore;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Objects;
using Xunit; using Xunit;
namespace Tests namespace Tests

View File

@ -3,7 +3,6 @@ using System.Threading.Tasks;
using SharedLibraryCore; using SharedLibraryCore;
using SharedLibraryCore.Interfaces; using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Configuration; using SharedLibraryCore.Configuration;
using SharedLibraryCore.Services; using SharedLibraryCore.Services;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
@ -99,7 +98,7 @@ namespace IW4MAdmin.Plugins.Welcome
using (var ctx = new DatabaseContext(disableTracking: true)) using (var ctx = new DatabaseContext(disableTracking: true))
{ {
penaltyReason = await ctx.Penalties penaltyReason = await ctx.Penalties
.Where(p => p.OffenderId == newPlayer.ClientId && p.Type == Penalty.PenaltyType.Flag) .Where(p => p.OffenderId == newPlayer.ClientId && p.Type == EFPenalty.PenaltyType.Flag)
.OrderByDescending(p => p.When) .OrderByDescending(p => p.When)
.Select(p => p.AutomatedOffense ?? p.Offense) .Select(p => p.AutomatedOffense ?? p.Offense)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();

View File

@ -2,7 +2,6 @@
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Objects;
namespace SharedLibraryCore namespace SharedLibraryCore
{ {

View File

@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Objects; using SharedLibraryCore.Helpers;
using SharedLibraryCore.Services; using SharedLibraryCore.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -284,7 +284,7 @@ namespace SharedLibraryCore.Commands
{ {
// todo: don't do the lookup here // todo: don't do the lookup here
var penalties = await E.Owner.Manager.GetPenaltyService().GetActivePenaltiesAsync(E.Target.AliasLinkId); var penalties = await E.Owner.Manager.GetPenaltyService().GetActivePenaltiesAsync(E.Target.AliasLinkId);
if (penalties.Where(p => p.Type == Penalty.PenaltyType.Ban || p.Type == Penalty.PenaltyType.TempBan).FirstOrDefault() != null) if (penalties.Where(p => p.Type == EFPenalty.PenaltyType.Ban || p.Type == EFPenalty.PenaltyType.TempBan).FirstOrDefault() != null)
{ {
switch ((await E.Target.Unban(E.Data, E.Origin).WaitAsync(Utilities.DefaultCommandTimeout, E.Owner.Manager.CancellationToken)).FailReason) switch ((await E.Target.Unban(E.Data, E.Origin).WaitAsync(Utilities.DefaultCommandTimeout, E.Owner.Manager.CancellationToken)).FailReason)
{ {
@ -957,7 +957,7 @@ namespace SharedLibraryCore.Commands
public override async Task ExecuteAsync(GameEvent E) public override async Task ExecuteAsync(GameEvent E)
{ {
var existingPenalties = await E.Owner.Manager.GetPenaltyService().GetActivePenaltiesAsync(E.Target.AliasLinkId, E.Target.IPAddress); var existingPenalties = await E.Owner.Manager.GetPenaltyService().GetActivePenaltiesAsync(E.Target.AliasLinkId, E.Target.IPAddress);
var penalty = existingPenalties.FirstOrDefault(b => b.Type > Penalty.PenaltyType.Kick); var penalty = existingPenalties.FirstOrDefault(b => b.Type > EFPenalty.PenaltyType.Kick);
if (penalty == null) if (penalty == null)
{ {
@ -965,7 +965,7 @@ namespace SharedLibraryCore.Commands
return; return;
} }
if (penalty.Type == Penalty.PenaltyType.Ban) if (penalty.Type == EFPenalty.PenaltyType.Ban)
{ {
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_BANINFO_SUCCESS"].FormatExt(E.Target.Name, penalty.Offense)); E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_BANINFO_SUCCESS"].FormatExt(E.Target.Name, penalty.Offense));
} }

View File

@ -35,26 +35,7 @@ namespace SharedLibraryCore.Database.Models
public string Password { get; set; } public string Password { get; set; }
public string PasswordSalt { get; set; } public string PasswordSalt { get; set; }
// list of meta for the client // list of meta for the client
public virtual ICollection<EFMeta> Meta { get; set; } public virtual ICollection<EFMeta> Meta { get; set; }
[NotMapped]
public virtual string Name
{
get { return CurrentAlias?.Name ?? "--"; }
set { if (CurrentAlias != null) CurrentAlias.Name = value; }
}
[NotMapped]
public virtual int? IPAddress
{
get { return CurrentAlias.IPAddress; }
set { CurrentAlias.IPAddress = value; }
}
[NotMapped]
public string IPAddressString => IPAddress.ConvertIPtoString();
[NotMapped]
public virtual IDictionary<int, long> LinkedAccounts { get; set; }
public virtual ICollection<EFPenalty> ReceivedPenalties { get; set; } public virtual ICollection<EFPenalty> ReceivedPenalties { get; set; }
public virtual ICollection<EFPenalty> AdministeredPenalties { get; set; } public virtual ICollection<EFPenalty> AdministeredPenalties { get; set; }
} }

View File

@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace SharedLibraryCore.Database.Models namespace SharedLibraryCore.Database.Models
{ {
public class EFPenalty : SharedEntity public partial class EFPenalty : SharedEntity
{ {
[Key] [Key]
public int PenaltyId { get; set; } public int PenaltyId { get; set; }
@ -29,6 +29,6 @@ namespace SharedLibraryCore.Database.Models
public string AutomatedOffense { get; set; } public string AutomatedOffense { get; set; }
[Required] [Required]
public bool IsEvadedOffense { get; set; } public bool IsEvadedOffense { get; set; }
public Objects.Penalty.PenaltyType Type { get; set; } public PenaltyType Type { get; set; }
} }
} }

View File

@ -1,6 +1,6 @@
using System; using System;
using static SharedLibraryCore.Database.Models.EFClient; using static SharedLibraryCore.Database.Models.EFClient;
using static SharedLibraryCore.Objects.Penalty; using static SharedLibraryCore.Database.Models.EFPenalty;
namespace SharedLibraryCore.Dtos namespace SharedLibraryCore.Dtos
{ {

View File

@ -181,6 +181,14 @@ namespace SharedLibraryCore
Other Other
} }
[Flags]
public enum EventRequiredEntity
{
None = 1,
Origin = 2,
Target = 4
}
static long NextEventId; static long NextEventId;
static long GetNextEventId() static long GetNextEventId()
{ {
@ -195,6 +203,7 @@ namespace SharedLibraryCore
} }
public EventType Type; public EventType Type;
public EventRequiredEntity RequiredEntity { get; set; }
public string Data; // Data is usually the message sent by player public string Data; // Data is usually the message sent by player
public string Message; public string Message;
public EFClient Origin; public EFClient Origin;

View File

@ -5,7 +5,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SharedLibraryCore.Objects namespace SharedLibraryCore.Helpers
{ {
public class Report public class Report
{ {

View File

@ -1,12 +1,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Services; using SharedLibraryCore.Services;
using SharedLibraryCore.Configuration; using SharedLibraryCore.Configuration;
using System.Reflection; using System.Reflection;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using System.Collections.Concurrent;
using System.Threading; using System.Threading;
namespace SharedLibraryCore.Interfaces namespace SharedLibraryCore.Interfaces

View File

@ -1,7 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Objects;
using SharedLibraryCore.RCon; using SharedLibraryCore.RCon;
using static SharedLibraryCore.Server; using static SharedLibraryCore.Server;

View File

@ -1,6 +1,6 @@
using static SharedLibraryCore.Database.Models.EFClient; using static SharedLibraryCore.Database.Models.EFClient;
namespace SharedLibraryCore.Objects namespace SharedLibraryCore.Localization
{ {
public sealed class ClientPermission public sealed class ClientPermission
{ {

View File

@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage.Internal;
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using SharedLibraryCore.Objects;
using System; using System;
namespace SharedLibraryCore.Migrations namespace SharedLibraryCore.Migrations

View File

@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage.Internal;
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using SharedLibraryCore.Objects;
using System; using System;
namespace SharedLibraryCore.Migrations namespace SharedLibraryCore.Migrations

View File

@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage.Internal;
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using SharedLibraryCore.Objects;
using System; using System;
namespace SharedLibraryCore.Migrations namespace SharedLibraryCore.Migrations

View File

@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage.Internal;
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using SharedLibraryCore.Objects;
using System; using System;
namespace SharedLibraryCore.Migrations namespace SharedLibraryCore.Migrations

View File

@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage.Internal;
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using SharedLibraryCore.Objects;
using System; using System;
namespace SharedLibraryCore.Migrations namespace SharedLibraryCore.Migrations

View File

@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage.Internal;
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using SharedLibraryCore.Objects;
using System; using System;
namespace SharedLibraryCore.Migrations namespace SharedLibraryCore.Migrations

View File

@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage.Internal;
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using SharedLibraryCore.Objects;
using System; using System;
namespace SharedLibraryCore.Migrations namespace SharedLibraryCore.Migrations

View File

@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage.Internal;
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using SharedLibraryCore.Objects;
using System; using System;
namespace SharedLibraryCore.Migrations namespace SharedLibraryCore.Migrations

View File

@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage.Internal;
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using SharedLibraryCore.Objects;
using System; using System;
namespace SharedLibraryCore.Migrations namespace SharedLibraryCore.Migrations

View File

@ -1,10 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SharedLibraryCore.Objects
{
class ClientStats
{
}
}

View File

@ -1,4 +1,4 @@
using SharedLibraryCore.Objects; using SharedLibraryCore.Localization;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@ -88,6 +88,24 @@ namespace SharedLibraryCore.Database.Models
return $"{CurrentAlias?.Name ?? "--"}::{NetworkId}"; return $"{CurrentAlias?.Name ?? "--"}::{NetworkId}";
} }
[NotMapped]
public virtual string Name
{
get { return CurrentAlias?.Name ?? "--"; }
set { if (CurrentAlias != null) CurrentAlias.Name = value; }
}
[NotMapped]
public virtual int? IPAddress
{
get { return CurrentAlias.IPAddress; }
set { CurrentAlias.IPAddress = value; }
}
[NotMapped]
public string IPAddressString => IPAddress.ConvertIPtoString();
[NotMapped]
public virtual IDictionary<int, long> LinkedAccounts { get; set; }
/// <summary> /// <summary>
/// send a message directly to the connected client /// send a message directly to the connected client
/// </summary> /// </summary>
@ -139,7 +157,6 @@ namespace SharedLibraryCore.Database.Models
return e; return e;
} }
/// <summary> /// <summary>
/// clear all warnings for a client /// clear all warnings for a client
/// </summary> /// </summary>
@ -429,7 +446,7 @@ namespace SharedLibraryCore.Database.Models
/// <summary> /// <summary>
/// Handles any client related logic on connection /// Handles any client related logic on connection
/// </summary> /// </summary>
public void OnConnect() public bool OnConnect()
{ {
var loc = Utilities.CurrentLocalization.LocalizationIndex; var loc = Utilities.CurrentLocalization.LocalizationIndex;
@ -440,7 +457,7 @@ namespace SharedLibraryCore.Database.Models
{ {
CurrentServer.Logger.WriteDebug($"Kicking {this} because their name is too short"); CurrentServer.Logger.WriteDebug($"Kicking {this} because their name is too short");
Kick(loc["SERVER_KICK_MINNAME"], Utilities.IW4MAdminClient(CurrentServer)); Kick(loc["SERVER_KICK_MINNAME"], Utilities.IW4MAdminClient(CurrentServer));
return; return false;
} }
if (CurrentServer.Manager.GetApplicationSettings().Configuration() if (CurrentServer.Manager.GetApplicationSettings().Configuration()
@ -449,14 +466,14 @@ namespace SharedLibraryCore.Database.Models
{ {
CurrentServer.Logger.WriteDebug($"Kicking {this} because their name is generic"); CurrentServer.Logger.WriteDebug($"Kicking {this} because their name is generic");
Kick(loc["SERVER_KICK_GENERICNAME"], Utilities.IW4MAdminClient(CurrentServer)); Kick(loc["SERVER_KICK_GENERICNAME"], Utilities.IW4MAdminClient(CurrentServer));
return; return false;
} }
if (Name.Where(c => char.IsControl(c)).Count() > 0) if (Name.Where(c => char.IsControl(c)).Count() > 0)
{ {
CurrentServer.Logger.WriteDebug($"Kicking {this} because their name contains control characters"); CurrentServer.Logger.WriteDebug($"Kicking {this} because their name contains control characters");
Kick(loc["SERVER_KICK_CONTROLCHARS"], Utilities.IW4MAdminClient(CurrentServer)); Kick(loc["SERVER_KICK_CONTROLCHARS"], Utilities.IW4MAdminClient(CurrentServer));
return; return false;
} }
// reserved slots stuff // reserved slots stuff
@ -468,8 +485,10 @@ namespace SharedLibraryCore.Database.Models
{ {
CurrentServer.Logger.WriteDebug($"Kicking {this} their spot is reserved"); CurrentServer.Logger.WriteDebug($"Kicking {this} their spot is reserved");
Kick(loc["SERVER_KICK_SLOT_IS_RESERVED"], Utilities.IW4MAdminClient(CurrentServer)); Kick(loc["SERVER_KICK_SLOT_IS_RESERVED"], Utilities.IW4MAdminClient(CurrentServer));
return; return false;
} }
return true;
} }
public async Task OnDisconnect() public async Task OnDisconnect()
@ -498,17 +517,12 @@ namespace SharedLibraryCore.Database.Models
{ {
IPAddress = ipAddress; IPAddress = ipAddress;
await CurrentServer.Manager.GetClientService().UpdateAlias(this); await CurrentServer.Manager.GetClientService().UpdateAlias(this);
} await CurrentServer.Manager.GetClientService().Update(this);
// we want to run any non GUID based logic here bool canConnect = await CanConnect(ipAddress);
OnConnect();
if (await CanConnect(ipAddress)) if (canConnect)
{
if (IPAddress != null)
{ {
await CurrentServer.Manager.GetClientService().Update(this);
var e = new GameEvent() var e = new GameEvent()
{ {
Type = GameEvent.EventType.Join, Type = GameEvent.EventType.Join,
@ -519,11 +533,16 @@ namespace SharedLibraryCore.Database.Models
CurrentServer.Manager.GetEventHandler().AddEvent(e); CurrentServer.Manager.GetEventHandler().AddEvent(e);
} }
else
{
CurrentServer.Logger.WriteDebug($"Client {this} is not allowed to join the server");
}
} }
else else
{ {
CurrentServer.Logger.WriteDebug($"Client {this} is not allowed to join the server"); CurrentServer.Logger.WriteDebug($"Client {this} does not have an IP yet");
} }
CurrentServer.Logger.WriteDebug($"OnJoin finished for {this}"); CurrentServer.Logger.WriteDebug($"OnJoin finished for {this}");
@ -538,7 +557,7 @@ namespace SharedLibraryCore.Database.Models
// kick them as their level is banned // kick them as their level is banned
if (Level == Permission.Banned) if (Level == Permission.Banned)
{ {
var profileBan = ReceivedPenalties.FirstOrDefault(_penalty => _penalty.Expires == null && _penalty.Active && _penalty.Type == Penalty.PenaltyType.Ban); var profileBan = ReceivedPenalties.FirstOrDefault(_penalty => _penalty.Expires == null && _penalty.Active && _penalty.Type == EFPenalty.PenaltyType.Ban);
if (profileBan == null) if (profileBan == null)
{ {
@ -547,7 +566,7 @@ namespace SharedLibraryCore.Database.Models
.GetPenaltyService() .GetPenaltyService()
.GetActivePenaltiesAsync(AliasLinkId)) .GetActivePenaltiesAsync(AliasLinkId))
.OrderByDescending(_penalty => _penalty.When) .OrderByDescending(_penalty => _penalty.When)
.FirstOrDefault(_penalty => _penalty.Type == Penalty.PenaltyType.Ban); .FirstOrDefault(_penalty => _penalty.Type == EFPenalty.PenaltyType.Ban);
CurrentServer.Logger.WriteWarning($"Client {this} is GUID banned, but no previous penalty exists for their ban"); CurrentServer.Logger.WriteWarning($"Client {this} is GUID banned, but no previous penalty exists for their ban");
@ -580,7 +599,7 @@ namespace SharedLibraryCore.Database.Models
#region CLIENT_GUID_TEMPBAN #region CLIENT_GUID_TEMPBAN
else else
{ {
var profileTempBan = ReceivedPenalties.FirstOrDefault(_penalty => _penalty.Type == Penalty.PenaltyType.TempBan && var profileTempBan = ReceivedPenalties.FirstOrDefault(_penalty => _penalty.Type == EFPenalty.PenaltyType.TempBan &&
_penalty.Active && _penalty.Active &&
_penalty.Expires > DateTime.UtcNow); _penalty.Expires > DateTime.UtcNow);
@ -598,7 +617,7 @@ namespace SharedLibraryCore.Database.Models
var activePenalties = await CurrentServer.Manager.GetPenaltyService().GetActivePenaltiesAsync(AliasLinkId, ipAddress); var activePenalties = await CurrentServer.Manager.GetPenaltyService().GetActivePenaltiesAsync(AliasLinkId, ipAddress);
#region CLIENT_LINKED_BAN #region CLIENT_LINKED_BAN
var currentBan = activePenalties.FirstOrDefault(p => p.Type == Penalty.PenaltyType.Ban); var currentBan = activePenalties.FirstOrDefault(p => p.Type == EFPenalty.PenaltyType.Ban);
// they have a perm ban tied to their AliasLink/profile // they have a perm ban tied to their AliasLink/profile
if (currentBan != null) if (currentBan != null)
@ -634,7 +653,7 @@ namespace SharedLibraryCore.Database.Models
#region CLIENT_LINKED_TEMPBAN #region CLIENT_LINKED_TEMPBAN
var tempBan = activePenalties var tempBan = activePenalties
.OrderByDescending(_penalty => _penalty.When) .OrderByDescending(_penalty => _penalty.When)
.FirstOrDefault(_penalty => _penalty.Type == Penalty.PenaltyType.TempBan); .FirstOrDefault(_penalty => _penalty.Type == EFPenalty.PenaltyType.TempBan);
// they have an active tempban tied to their AliasLink // they have an active tempban tied to their AliasLink
if (tempBan != null) if (tempBan != null)
@ -648,7 +667,7 @@ namespace SharedLibraryCore.Database.Models
#region CLIENT_LINKED_FLAG #region CLIENT_LINKED_FLAG
if (Level != Permission.Flagged) if (Level != Permission.Flagged)
{ {
var currentFlag = activePenalties.FirstOrDefault(_penalty => _penalty.Type == Penalty.PenaltyType.Flag); var currentFlag = activePenalties.FirstOrDefault(_penalty => _penalty.Type == EFPenalty.PenaltyType.Flag);
if (currentFlag != null) if (currentFlag != null)
{ {
@ -661,7 +680,7 @@ namespace SharedLibraryCore.Database.Models
if (Level == Permission.Flagged) if (Level == Permission.Flagged)
{ {
var currentAutoFlag = activePenalties var currentAutoFlag = activePenalties
.Where(p => p.Type == Penalty.PenaltyType.Flag && p.PunisherId == 1) .Where(p => p.Type == EFPenalty.PenaltyType.Flag && p.PunisherId == 1)
.OrderByDescending(p => p.When) .OrderByDescending(p => p.When)
.FirstOrDefault(); .FirstOrDefault();
@ -674,7 +693,7 @@ namespace SharedLibraryCore.Database.Models
} }
} }
return true; return true && OnConnect();
} }
[NotMapped] [NotMapped]

View File

@ -1,9 +1,9 @@
using System; using System;
using SharedLibraryCore; using SharedLibraryCore;
namespace SharedLibraryCore.Objects namespace SharedLibraryCore.Database.Models
{ {
public class Penalty : Database.Models.EFPenalty public partial class EFPenalty
{ {
public enum PenaltyType public enum PenaltyType
{ {

View File

@ -5,7 +5,6 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using SharedLibraryCore.Helpers; using SharedLibraryCore.Helpers;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Dtos; using SharedLibraryCore.Dtos;
using SharedLibraryCore.Configuration; using SharedLibraryCore.Configuration;
using SharedLibraryCore.Interfaces; using SharedLibraryCore.Interfaces;

View File

@ -2,7 +2,6 @@
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Dtos; using SharedLibraryCore.Dtos;
using SharedLibraryCore.Objects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -2,7 +2,6 @@
using SharedLibraryCore.Database; using SharedLibraryCore.Database;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Dtos; using SharedLibraryCore.Dtos;
using SharedLibraryCore.Objects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -45,7 +44,7 @@ namespace SharedLibraryCore.Services
await iqLinkedProfiles.ForEachAsync(_client => await iqLinkedProfiles.ForEachAsync(_client =>
{ {
newEntity.Punisher.CurrentServer?.Logger.WriteDebug($"Applying penalty to linked client {_client.ClientId}");
var linkedPenalty = new EFPenalty() var linkedPenalty = new EFPenalty()
{ {
OffenderId = _client.ClientId, OffenderId = _client.ClientId,
@ -94,12 +93,12 @@ namespace SharedLibraryCore.Services
throw new NotImplementedException(); throw new NotImplementedException();
} }
public async Task<IList<PenaltyInfo>> GetRecentPenalties(int count, int offset, Penalty.PenaltyType showOnly = Penalty.PenaltyType.Any) public async Task<IList<PenaltyInfo>> GetRecentPenalties(int count, int offset, EFPenalty.PenaltyType showOnly = EFPenalty.PenaltyType.Any)
{ {
using (var context = new DatabaseContext(true)) using (var context = new DatabaseContext(true))
{ {
var iqPenalties = context.Penalties var iqPenalties = context.Penalties
.Where(p => showOnly == Penalty.PenaltyType.Any ? p.Type != Penalty.PenaltyType.Any : p.Type == showOnly) .Where(p => showOnly == EFPenalty.PenaltyType.Any ? p.Type != EFPenalty.PenaltyType.Any : p.Type == showOnly)
.OrderByDescending(p => p.When) .OrderByDescending(p => p.When)
.Skip(offset) .Skip(offset)
.Take(count) .Take(count)
@ -173,11 +172,11 @@ namespace SharedLibraryCore.Services
{ {
var now = DateTime.UtcNow; var now = DateTime.UtcNow;
Expression<Func<EFPenalty, bool>> filter = (p) => new Penalty.PenaltyType[] Expression<Func<EFPenalty, bool>> filter = (p) => new EFPenalty.PenaltyType[]
{ {
Penalty.PenaltyType.TempBan, EFPenalty.PenaltyType.TempBan,
Penalty.PenaltyType.Ban, EFPenalty.PenaltyType.Ban,
Penalty.PenaltyType.Flag EFPenalty.PenaltyType.Flag
}.Contains(p.Type) && }.Contains(p.Type) &&
p.Active && p.Active &&
(p.Expires == null || p.Expires > now); (p.Expires == null || p.Expires > now);

View File

@ -15,7 +15,7 @@ using System.Reflection;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using static SharedLibraryCore.Objects.Penalty; using static SharedLibraryCore.Database.Models.EFPenalty;
using static SharedLibraryCore.Server; using static SharedLibraryCore.Server;
namespace SharedLibraryCore namespace SharedLibraryCore

View File

@ -7,6 +7,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using static SharedLibraryCore.Database.Models.EFPenalty;
namespace WebfrontCore.Controllers namespace WebfrontCore.Controllers
{ {
@ -66,7 +67,7 @@ namespace WebfrontCore.Controllers
var currentPenalty = activePenalties.FirstOrDefault(); var currentPenalty = activePenalties.FirstOrDefault();
if (currentPenalty != null && currentPenalty.Type == SharedLibraryCore.Objects.Penalty.PenaltyType.TempBan) if (currentPenalty != null && currentPenalty.Type == PenaltyType.TempBan)
{ {
clientDto.Meta.Add(new ProfileMeta() clientDto.Meta.Add(new ProfileMeta()
{ {

View File

@ -10,7 +10,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using WebfrontCore.ViewComponents; using WebfrontCore.ViewComponents;
using static SharedLibraryCore.Objects.Penalty; using static SharedLibraryCore.Database.Models.EFPenalty;
namespace WebfrontCore.Controllers namespace WebfrontCore.Controllers
{ {

View File

@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore.Objects; using SharedLibraryCore.Database.Models;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -9,7 +9,7 @@ namespace WebfrontCore.ViewComponents
{ {
private const int PENALTY_COUNT = 15; private const int PENALTY_COUNT = 15;
public async Task<IViewComponentResult> InvokeAsync(int offset, Penalty.PenaltyType showOnly) public async Task<IViewComponentResult> InvokeAsync(int offset, EFPenalty.PenaltyType showOnly)
{ {
var penalties = await Program.Manager.GetPenaltyService().GetRecentPenalties(PENALTY_COUNT, offset, showOnly); var penalties = await Program.Manager.GetPenaltyService().GetRecentPenalties(PENALTY_COUNT, offset, showOnly);
penalties = User.Identity.IsAuthenticated ? penalties : penalties.Where(p => !p.Sensitive).ToList(); penalties = User.Identity.IsAuthenticated ? penalties : penalties.Where(p => !p.Sensitive).ToList();

View File

@ -1,13 +1,10 @@
using System; using static SharedLibraryCore.Database.Models.EFPenalty;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebfrontCore.ViewModels namespace WebfrontCore.ViewModels
{ {
public class PenaltyFilterInfo public class PenaltyFilterInfo
{ {
public int Offset { get; set; } public int Offset { get; set; }
public SharedLibraryCore.Objects.Penalty.PenaltyType ShowOnly { get; set; } public PenaltyType ShowOnly { get; set; }
} }
} }

View File

@ -1,4 +1,4 @@
@model SharedLibraryCore.Objects.Penalty.PenaltyType @model SharedLibraryCore.Database.Models.EFPenalty.PenaltyType
@{ @{
var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex; var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex;
} }
@ -6,11 +6,11 @@
<div class="row"> <div class="row">
<select class="form-control bg-dark text-muted" id="penalty_filter_selection"> <select class="form-control bg-dark text-muted" id="penalty_filter_selection">
@{ @{
foreach (var penaltyType in Enum.GetValues(typeof(SharedLibraryCore.Objects.Penalty.PenaltyType))) foreach (var penaltyType in Enum.GetValues(typeof(SharedLibraryCore.Database.Models.EFPenalty.PenaltyType)))
{ {
if ((SharedLibraryCore.Objects.Penalty.PenaltyType)penaltyType == SharedLibraryCore.Objects.Penalty.PenaltyType.Any) if ((SharedLibraryCore.Database.Models.EFPenalty.PenaltyType)penaltyType == SharedLibraryCore.Database.Models.EFPenalty.PenaltyType.Any)
{ {
if (Model == SharedLibraryCore.Objects.Penalty.PenaltyType.Any) if (Model == SharedLibraryCore.Database.Models.EFPenalty.PenaltyType.Any)
{ {
<option value="@Convert.ToInt32(penaltyType)" selected="selected" )>@loc["WEBFRONT_PENALTY_TEMPLATE_SHOW"] @penaltyType.ToString()</option> <option value="@Convert.ToInt32(penaltyType)" selected="selected" )>@loc["WEBFRONT_PENALTY_TEMPLATE_SHOW"] @penaltyType.ToString()</option>
} }
@ -21,7 +21,7 @@
} }
else else
{ {
if ((SharedLibraryCore.Objects.Penalty.PenaltyType)penaltyType == Model) if ((SharedLibraryCore.Database.Models.EFPenalty.PenaltyType)penaltyType == Model)
{ {
<option value="@Convert.ToInt32(penaltyType)" selected="selected">@loc["WEBFRONT_PENALTY_TEMPLATE_SHOWONLY"] @penaltyType.ToString()s</option> <option value="@Convert.ToInt32(penaltyType)" selected="selected">@loc["WEBFRONT_PENALTY_TEMPLATE_SHOWONLY"] @penaltyType.ToString()s</option>
} }

View File

@ -73,7 +73,7 @@
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.2" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />