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

View File

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

View File

@ -104,7 +104,8 @@ namespace IW4MAdmin.Application.EventParsers
Type = GameEvent.EventType.Command,
Data = message,
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,
Data = message,
Origin = new EFClient() { NetworkId = originId },
Message = message
Message = message,
RequiredEntity = GameEvent.EventRequiredEntity.Origin
};
}
}
@ -121,13 +123,12 @@ namespace IW4MAdmin.Application.EventParsers
if (eventType == "K")
{
var match = Regex.Match(logLine, Configuration.Kill.Pattern);
if (match.Success)
{
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()
{
@ -135,27 +136,29 @@ namespace IW4MAdmin.Application.EventParsers
Data = logLine,
Origin = new EFClient() { NetworkId = originId },
Target = new EFClient() { NetworkId = targetId },
RequiredEntity = GameEvent.EventRequiredEntity.Origin | GameEvent.EventRequiredEntity.Target
};
}
}
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);
long targetId = regexMatch.Groups[Configuration.Damage.GroupMapping[ParserRegex.GroupType.TargetNetworkId]].ToString().ConvertGuidToLong();
return new GameEvent()
{
Type = GameEvent.EventType.Damage,
Data = logLine,
Origin = new EFClient() { NetworkId = originId },
Target = new EFClient() { NetworkId = targetId }
};
}
Type = GameEvent.EventType.Damage,
Data = logLine,
Origin = new EFClient() { NetworkId = originId },
Target = new EFClient() { NetworkId = targetId },
RequiredEntity = GameEvent.EventRequiredEntity.Origin | GameEvent.EventRequiredEntity.Target
};
}
}
if (eventType == "J")
@ -177,7 +180,8 @@ namespace IW4MAdmin.Application.EventParsers
NetworkId = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(),
ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()),
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(),
ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()),
State = EFClient.ClientState.Disconnecting
}
},
RequiredEntity = GameEvent.EventRequiredEntity.Origin
};
}
}
@ -213,6 +218,7 @@ namespace IW4MAdmin.Application.EventParsers
Data = lineSplit[0],
Origin = Utilities.IW4MAdminClient(),
Target = Utilities.IW4MAdminClient(),
RequiredEntity = GameEvent.EventRequiredEntity.None
};
}
@ -226,7 +232,8 @@ namespace IW4MAdmin.Application.EventParsers
Data = lineSplit[0],
Origin = 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,
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")
{
long originId = lineSplit[1].ConvertGuidToLong(1);
long targetId = lineSplit[2].ConvertGuidToLong();
long targetId = lineSplit[2].ConvertGuidToLong(1);
return new GameEvent()
{
Type = GameEvent.EventType.ScriptKill,
Data = logLine,
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")
{
long originId = lineSplit[1].ConvertGuidToLong(1);
long targetId = lineSplit[2].ConvertGuidToLong();
long targetId = lineSplit[2].ConvertGuidToLong(1);
return new GameEvent()
{
Type = GameEvent.EventType.ScriptDamage,
Data = logLine,
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,
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))))
{
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);
gameEvent.Target = gameEvent.Target == null || gameEvent.Target.NetworkId == 1 ? gameEvent.Target : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Target.NetworkId);
if ((gameEvent.RequiredEntity & GameEvent.EventRequiredEntity.Origin) == GameEvent.EventRequiredEntity.Origin && gameEvent.Origin.NetworkId != 1)
{
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);
}

View File

@ -65,9 +65,26 @@ namespace IW4MAdmin.Application.IO
if (!ignoreBots.Value || (ignoreBots.Value && !((gameEvent.Origin?.IsBot ?? false) || (gameEvent.Target?.IsBot ?? false))))
{
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);
gameEvent.Target = gameEvent.Target == null || gameEvent.Target.NetworkId == 1 ? gameEvent.Target : server.GetClientsAsList().First(_client => _client.NetworkId == gameEvent.Target.NetworkId);
if ((gameEvent.RequiredEntity & GameEvent.EventRequiredEntity.Origin) == GameEvent.EventRequiredEntity.Origin && gameEvent.Origin.NetworkId != 1)
{
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);
}

View File

@ -6,9 +6,9 @@ using SharedLibraryCore.Configuration;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Dtos;
using SharedLibraryCore.Exceptions;
using SharedLibraryCore.Helpers;
using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Localization;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Services;
using System;
using System.Collections.Generic;
@ -74,9 +74,9 @@ namespace IW4MAdmin
Type = GameEvent.EventType.Connect
};
Manager.GetEventHandler().AddEvent(e);
await client.OnJoin(client.IPAddress);
client.State = ClientState.Connected;
Manager.GetEventHandler().AddEvent(e);
}
override public async Task OnClientDisconnected(EFClient client)
@ -249,7 +249,7 @@ namespace IW4MAdmin
// for some reason there's still a client in the spot
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]);
goto CONNECT;
}
@ -258,9 +258,9 @@ namespace IW4MAdmin
else if (E.Type == GameEvent.EventType.Flag)
{
// 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,
Offender = E.Target,
Offense = E.Data,
@ -275,9 +275,9 @@ namespace IW4MAdmin
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,
Offender = E.Target,
Offense = E.Data,
@ -299,9 +299,9 @@ namespace IW4MAdmin
Reason = E.Data
});
Penalty newReport = new Penalty()
var newReport = new EFPenalty()
{
Type = Penalty.PenaltyType.Report,
Type = EFPenalty.PenaltyType.Report,
Expires = DateTime.UtcNow,
Offender = E.Target,
Offense = E.Message,
@ -620,7 +620,7 @@ namespace IW4MAdmin
foreach (var client in polledClients[0])
{
// 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;
}
@ -898,9 +898,9 @@ namespace IW4MAdmin
Target.CurrentServer.Broadcast(message);
}
Penalty newPenalty = new Penalty()
var newPenalty = new EFPenalty()
{
Type = Penalty.PenaltyType.Warning,
Type = EFPenalty.PenaltyType.Warning,
Expires = DateTime.UtcNow,
Offender = Target,
Punisher = Origin,
@ -937,9 +937,9 @@ namespace IW4MAdmin
await Target.CurrentServer.OnClientDisconnected(Target);
#endif
var newPenalty = new Penalty()
var newPenalty = new EFPenalty()
{
Type = Penalty.PenaltyType.Kick,
Type = EFPenalty.PenaltyType.Kick,
Expires = DateTime.UtcNow,
Offender = Target,
Offense = Reason,
@ -974,9 +974,9 @@ namespace IW4MAdmin
await Target.CurrentServer.OnClientDisconnected(Target);
#endif
Penalty newPenalty = new Penalty()
var newPenalty = new EFPenalty()
{
Type = Penalty.PenaltyType.TempBan,
Type = EFPenalty.PenaltyType.TempBan,
Expires = DateTime.UtcNow + length,
Offender = Target,
Offense = Reason,
@ -1008,7 +1008,6 @@ namespace IW4MAdmin
else
{
#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");
await targetClient.CurrentServer.ExecuteCommandAsync(formattedString);
@ -1017,9 +1016,9 @@ namespace IW4MAdmin
#endif
}
Penalty newPenalty = new Penalty()
EFPenalty newPenalty = new EFPenalty()
{
Type = Penalty.PenaltyType.Ban,
Type = EFPenalty.PenaltyType.Ban,
Expires = null,
Offender = targetClient,
Offense = reason,
@ -1027,7 +1026,6 @@ namespace IW4MAdmin
Link = targetClient.AliasLink,
AutomatedOffense = originClient.AdministeredPenalties?.FirstOrDefault()?.AutomatedOffense,
IsEvadedOffense = isEvade
};
targetClient.SetLevel(Permission.Banned, originClient);
@ -1036,9 +1034,9 @@ namespace IW4MAdmin
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,
Offender = Target,
Offense = reason,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,6 @@ using SharedLibraryCore.Database;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Helpers;
using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Objects;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@ -614,7 +613,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
var penaltyClient = Utilities.IW4MAdminClient(attacker.CurrentServer);
switch (penalty.ClientPenalty)
{
case Penalty.PenaltyType.Ban:
case EFPenalty.PenaltyType.Ban:
if (attacker.Level == EFClient.Permission.Banned)
{
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);
break;
case Penalty.PenaltyType.Flag:
case EFPenalty.PenaltyType.Flag:
if (attacker.Level != EFClient.Permission.User)
{
break;
@ -1231,6 +1230,11 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
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());
id = id < 0 ? Math.Abs(id) : id;
long? serverId;

View File

@ -80,7 +80,7 @@ namespace IW4MAdmin.Plugins.Stats
if (killInfo.Length >= 14 && !ShouldIgnoreEvent(E.Origin, E.Target))
{
// this treats "world" damage as self damage
if (E.Origin.ClientId == 1)
if (IsWorldDamage(E.Origin))
{
E.Origin = E.Target;
}
@ -93,7 +93,7 @@ namespace IW4MAdmin.Plugins.Stats
if (!E.Owner.CustomCallback && !ShouldIgnoreEvent(E.Origin, E.Target))
{
// this treats "world" damage as self damage
if (E.Origin.ClientId == 1)
if (IsWorldDamage(E.Origin))
{
E.Origin = E.Target;
}
@ -105,7 +105,7 @@ namespace IW4MAdmin.Plugins.Stats
if (!E.Owner.CustomCallback && !ShouldIgnoreEvent(E.Origin, E.Target))
{
// this treats "world" damage as self damage
if (E.Origin.ClientId == 1)
if (IsWorldDamage(E.Origin))
{
E.Origin = E.Target;
}
@ -118,7 +118,7 @@ namespace IW4MAdmin.Plugins.Stats
if (killInfo.Length >= 14 && !ShouldIgnoreEvent(E.Origin, E.Target))
{
// this treats "world" damage as self damage
if (E.Origin.ClientId == 1)
if (IsWorldDamage(E.Origin))
{
E.Origin = E.Target;
}
@ -471,7 +471,14 @@ namespace IW4MAdmin.Plugins.Stats
/// <returns></returns>
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.Commands;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
@ -218,7 +217,7 @@ namespace Tests
Owner = client.CurrentServer
}).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");
}
@ -243,7 +242,7 @@ namespace Tests
Owner = client.CurrentServer
}).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");
var unbanCommand = new CUnban();
@ -256,7 +255,7 @@ namespace Tests
Owner = client.CurrentServer
}).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");
}

View File

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

View File

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

View File

@ -3,7 +3,6 @@ using System.Threading.Tasks;
using SharedLibraryCore;
using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Services;
using SharedLibraryCore.Database.Models;
@ -99,7 +98,7 @@ namespace IW4MAdmin.Plugins.Welcome
using (var ctx = new DatabaseContext(disableTracking: true))
{
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)
.Select(p => p.AutomatedOffense ?? p.Offense)
.FirstOrDefaultAsync();

View File

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

View File

@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore;
using SharedLibraryCore.Database;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Helpers;
using SharedLibraryCore.Services;
using System;
using System.Collections.Generic;
@ -284,7 +284,7 @@ namespace SharedLibraryCore.Commands
{
// todo: don't do the lookup here
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)
{
@ -957,7 +957,7 @@ namespace SharedLibraryCore.Commands
public override async Task ExecuteAsync(GameEvent E)
{
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)
{
@ -965,7 +965,7 @@ namespace SharedLibraryCore.Commands
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));
}

View File

@ -35,26 +35,7 @@ namespace SharedLibraryCore.Database.Models
public string Password { get; set; }
public string PasswordSalt { get; set; }
// list of meta for the client
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<EFMeta> Meta { get; set; }
public virtual ICollection<EFPenalty> ReceivedPenalties { get; set; }
public virtual ICollection<EFPenalty> AdministeredPenalties { get; set; }
}

View File

@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace SharedLibraryCore.Database.Models
{
public class EFPenalty : SharedEntity
public partial class EFPenalty : SharedEntity
{
[Key]
public int PenaltyId { get; set; }
@ -29,6 +29,6 @@ namespace SharedLibraryCore.Database.Models
public string AutomatedOffense { get; set; }
[Required]
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 static SharedLibraryCore.Database.Models.EFClient;
using static SharedLibraryCore.Objects.Penalty;
using static SharedLibraryCore.Database.Models.EFPenalty;
namespace SharedLibraryCore.Dtos
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal;
using SharedLibraryCore.Database;
using SharedLibraryCore.Objects;
using System;
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.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
@ -88,6 +88,24 @@ namespace SharedLibraryCore.Database.Models
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>
/// send a message directly to the connected client
/// </summary>
@ -139,7 +157,6 @@ namespace SharedLibraryCore.Database.Models
return e;
}
/// <summary>
/// clear all warnings for a client
/// </summary>
@ -429,7 +446,7 @@ namespace SharedLibraryCore.Database.Models
/// <summary>
/// Handles any client related logic on connection
/// </summary>
public void OnConnect()
public bool OnConnect()
{
var loc = Utilities.CurrentLocalization.LocalizationIndex;
@ -440,7 +457,7 @@ namespace SharedLibraryCore.Database.Models
{
CurrentServer.Logger.WriteDebug($"Kicking {this} because their name is too short");
Kick(loc["SERVER_KICK_MINNAME"], Utilities.IW4MAdminClient(CurrentServer));
return;
return false;
}
if (CurrentServer.Manager.GetApplicationSettings().Configuration()
@ -449,14 +466,14 @@ namespace SharedLibraryCore.Database.Models
{
CurrentServer.Logger.WriteDebug($"Kicking {this} because their name is generic");
Kick(loc["SERVER_KICK_GENERICNAME"], Utilities.IW4MAdminClient(CurrentServer));
return;
return false;
}
if (Name.Where(c => char.IsControl(c)).Count() > 0)
{
CurrentServer.Logger.WriteDebug($"Kicking {this} because their name contains control characters");
Kick(loc["SERVER_KICK_CONTROLCHARS"], Utilities.IW4MAdminClient(CurrentServer));
return;
return false;
}
// reserved slots stuff
@ -468,8 +485,10 @@ namespace SharedLibraryCore.Database.Models
{
CurrentServer.Logger.WriteDebug($"Kicking {this} their spot is reserved");
Kick(loc["SERVER_KICK_SLOT_IS_RESERVED"], Utilities.IW4MAdminClient(CurrentServer));
return;
return false;
}
return true;
}
public async Task OnDisconnect()
@ -498,17 +517,12 @@ namespace SharedLibraryCore.Database.Models
{
IPAddress = ipAddress;
await CurrentServer.Manager.GetClientService().UpdateAlias(this);
}
await CurrentServer.Manager.GetClientService().Update(this);
// we want to run any non GUID based logic here
OnConnect();
bool canConnect = await CanConnect(ipAddress);
if (await CanConnect(ipAddress))
{
if (IPAddress != null)
if (canConnect)
{
await CurrentServer.Manager.GetClientService().Update(this);
var e = new GameEvent()
{
Type = GameEvent.EventType.Join,
@ -519,11 +533,16 @@ namespace SharedLibraryCore.Database.Models
CurrentServer.Manager.GetEventHandler().AddEvent(e);
}
else
{
CurrentServer.Logger.WriteDebug($"Client {this} is not allowed to join the server");
}
}
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}");
@ -538,7 +557,7 @@ namespace SharedLibraryCore.Database.Models
// kick them as their level is 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)
{
@ -547,7 +566,7 @@ namespace SharedLibraryCore.Database.Models
.GetPenaltyService()
.GetActivePenaltiesAsync(AliasLinkId))
.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");
@ -580,7 +599,7 @@ namespace SharedLibraryCore.Database.Models
#region CLIENT_GUID_TEMPBAN
else
{
var profileTempBan = ReceivedPenalties.FirstOrDefault(_penalty => _penalty.Type == Penalty.PenaltyType.TempBan &&
var profileTempBan = ReceivedPenalties.FirstOrDefault(_penalty => _penalty.Type == EFPenalty.PenaltyType.TempBan &&
_penalty.Active &&
_penalty.Expires > DateTime.UtcNow);
@ -598,7 +617,7 @@ namespace SharedLibraryCore.Database.Models
var activePenalties = await CurrentServer.Manager.GetPenaltyService().GetActivePenaltiesAsync(AliasLinkId, ipAddress);
#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
if (currentBan != null)
@ -634,7 +653,7 @@ namespace SharedLibraryCore.Database.Models
#region CLIENT_LINKED_TEMPBAN
var tempBan = activePenalties
.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
if (tempBan != null)
@ -648,7 +667,7 @@ namespace SharedLibraryCore.Database.Models
#region CLIENT_LINKED_FLAG
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)
{
@ -661,7 +680,7 @@ namespace SharedLibraryCore.Database.Models
if (Level == Permission.Flagged)
{
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)
.FirstOrDefault();
@ -674,7 +693,7 @@ namespace SharedLibraryCore.Database.Models
}
}
return true;
return true && OnConnect();
}
[NotMapped]

View File

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

View File

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

View File

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

View File

@ -2,7 +2,6 @@
using SharedLibraryCore.Database;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Dtos;
using SharedLibraryCore.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
@ -45,7 +44,7 @@ namespace SharedLibraryCore.Services
await iqLinkedProfiles.ForEachAsync(_client =>
{
newEntity.Punisher.CurrentServer?.Logger.WriteDebug($"Applying penalty to linked client {_client.ClientId}");
var linkedPenalty = new EFPenalty()
{
OffenderId = _client.ClientId,
@ -94,12 +93,12 @@ namespace SharedLibraryCore.Services
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))
{
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)
.Skip(offset)
.Take(count)
@ -173,11 +172,11 @@ namespace SharedLibraryCore.Services
{
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,
Penalty.PenaltyType.Ban,
Penalty.PenaltyType.Flag
EFPenalty.PenaltyType.TempBan,
EFPenalty.PenaltyType.Ban,
EFPenalty.PenaltyType.Flag
}.Contains(p.Type) &&
p.Active &&
(p.Expires == null || p.Expires > now);

View File

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

View File

@ -7,6 +7,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static SharedLibraryCore.Database.Models.EFPenalty;
namespace WebfrontCore.Controllers
{
@ -66,7 +67,7 @@ namespace WebfrontCore.Controllers
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()
{

View File

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

View File

@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Database.Models;
using System.Linq;
using System.Threading.Tasks;
@ -9,7 +9,7 @@ namespace WebfrontCore.ViewComponents
{
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);
penalties = User.Identity.IsAuthenticated ? penalties : penalties.Where(p => !p.Sensitive).ToList();

View File

@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static SharedLibraryCore.Database.Models.EFPenalty;
namespace WebfrontCore.ViewModels
{
public class PenaltyFilterInfo
{
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;
}
@ -6,11 +6,11 @@
<div class="row">
<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>
}
@ -21,7 +21,7 @@
}
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>
}

View File

@ -73,7 +73,7 @@
<PackageReference Include="Microsoft.AspNetCore.Hosting" 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.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.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />