Compare commits

..

29 Commits

Author SHA1 Message Date
8baa85c7c0 update max name length to 34 for base kill/damage parser 2021-12-23 13:12:12 -06:00
ecfcd760d6 fix color code issue 2021-12-19 20:02:00 -06:00
8af40a7772 update custom callbacks to properly exit thread on disconnect 2021-12-19 20:01:35 -06:00
697a1884cb work around for iw5/t6 not being able to parse multiple commands over rcon for mag command 2021-11-28 21:05:08 -06:00
4899ef86cc update to show full gametype name on webfront 2021-11-28 10:17:56 -06:00
794e1ee87b implement map and gametype command 2021-11-28 10:04:37 -06:00
b025115cf8 add color code mapping for CSGO 2021-11-26 20:49:58 -06:00
f7c3db3712 fix concurrency issue with accent color setup 2021-11-24 09:49:44 -06:00
f32ac3f45e abstract engine color codes to use (Color::<Color>) format to make codes more.
see pt6 parser and configs for example usages
2021-11-23 17:26:33 -06:00
3716255740 fix issue with caching implementation 2021-11-21 15:33:44 -06:00
d36e19a077 try renable FTP publish 2021-11-20 20:37:11 -06:00
12cc5f1820 update help command to use per game commands 2021-11-20 20:32:15 -06:00
61a131be9d fix plugin error formatting 2021-11-20 19:01:25 -06:00
d93bfc11d0 update caching to use automatic timer instead of request based to prevent task cancellation 2021-11-15 10:25:55 -06:00
21f290ca58 add default port and rcon password hint during setup 2021-11-14 21:38:00 -06:00
d3df9623aa add console log sink for critical errors 2021-11-13 21:24:51 -06:00
1b9ca676dc update plugin error message format 2021-11-13 21:19:44 -06:00
58616e18fe Merge branch 'release/pre' of https://github.com/RaidMax/IW4M-Admin into release/pre 2021-11-04 19:10:37 -05:00
0dcbafd0f2 update webfront ip lookup to bypass api key restriction 2021-11-04 19:10:10 -05:00
f8723e6a8c Add Pluto IW5 Maps from r2385 (#220) 2021-11-03 18:53:23 -05:00
3ebdbde33d fix issue with assigning correct server when processing command 2021-11-03 18:51:52 -05:00
769faaa31b update country flag api 2021-11-02 18:12:47 -05:00
2734a3f138 remove javascript error log trying to load hljs from non config pages 2021-11-02 18:02:04 -05:00
914b37b20a temporarily disable ftp release integration to bypass unknown Error: connect ETIMEDOUT *:21 (control socket) 2021-11-01 21:28:00 -05:00
755c149495 update welcome plugin to bypass api lookup limitation 2021-11-01 17:06:17 -05:00
bbcbc4c042 cleanup and enhance penalty handling 2021-10-31 11:57:32 -05:00
f3bead8eb5 reduce timeout when master api is down 2021-10-30 19:42:07 -05:00
7eb45f2bc9 fix issue with detecting bans on accounts with new ips when implicit linking is disabled 2021-10-20 11:16:35 -05:00
5837885653 post webfront url to master 2021-10-19 21:33:21 -05:00
60 changed files with 240 additions and 5036 deletions

View File

@ -492,17 +492,13 @@ namespace IW4MAdmin.Application
// this is because I want to store the command prefix in IW4MAdminSettings, but can't easily
// inject it to all the places that need it
cmdConfig.CommandPrefix = _appConfig?.CommandPrefix ?? "!";
cmdConfig.BroadcastCommandPrefix = _appConfig?.BroadcastCommandPrefix ?? "@";
cmdConfig.CommandPrefix = _appConfig.CommandPrefix;
cmdConfig.BroadcastCommandPrefix = _appConfig.BroadcastCommandPrefix;
foreach (var cmd in commandsToAddToConfig)
{
if (cmdConfig.Commands.ContainsKey(cmd.CommandConfigNameForType()))
{
continue;
}
cmdConfig.Commands.Add(cmd.CommandConfigNameForType(),
new CommandProperties
new CommandProperties()
{
Name = cmd.Name,
Alias = cmd.Alias,

View File

@ -159,12 +159,12 @@
"Game": "IW5",
"Gametypes": [
{
"Name": "dom",
"Alias": "Domination"
"Name": "tdm",
"Alias": "Team Deathmatch"
},
{
"Name": "conf",
"Alias": "Kill Confirmed"
"Name": "dom",
"Alias": "Domination"
},
{
"Name": "ctf",
@ -175,29 +175,37 @@
"Alias": "Demolition"
},
{
"Name": "dm",
"Alias": "Free For All"
},
{
"Name": "grnd",
"Name": "dz",
"Alias": "Drop Zone"
},
{
"Name": "gun",
"Name": "ffa",
"Alias": "Free For All"
},
{
"Name": "gg",
"Alias": "Gun Game"
},
{
"Name": "hq",
"Alias": "Headquarters"
},
{
"Name": "koth",
"Alias": "Headquarters"
},
{
"Name": "infect",
"Name": "inf",
"Alias": "Infected"
},
{
"Name": "jugg",
"Name": "jug",
"Alias": "Juggernaut"
},
{
"Name": "kc",
"Alias": "Kill Confirmed"
},
{
"Name": "oic",
"Alias": "One In The Chamber"
@ -215,12 +223,8 @@
"Alias": "Team Defender"
},
{
"Name": "tjugg",
"Name": "tj",
"Alias": "Team Juggernaut"
},
{
"Name": "war",
"Alias": "Team Deathmatch"
}
]
},

View File

@ -118,7 +118,7 @@ namespace Data.Context
ent.HasIndex(a => a.Name);
ent.Property(_alias => _alias.SearchableName).HasMaxLength(24);
ent.HasIndex(_alias => _alias.SearchableName);
ent.HasIndex(_alias => new {_alias.Name, _alias.IPAddress});
ent.HasIndex(_alias => new {_alias.Name, _alias.IPAddress}).IsUnique();
});
modelBuilder.Entity<EFMeta>(ent =>
@ -145,4 +145,4 @@ namespace Data.Context
base.OnModelCreating(modelBuilder);
}
}
}
}

View File

@ -8,7 +8,7 @@
<PackageId>RaidMax.IW4MAdmin.Data</PackageId>
<Title>RaidMax.IW4MAdmin.Data</Title>
<Authors />
<PackageVersion>1.1.0</PackageVersion>
<PackageVersion>1.0.9</PackageVersion>
</PropertyGroup>
<ItemGroup>

View File

@ -1,32 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Data.Migrations.MySql
{
public partial class RemoveUniqueAliasIndexConstraint : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias");
migrationBuilder.CreateIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias",
columns: new[] { "Name", "IPAddress" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias");
migrationBuilder.CreateIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias",
columns: new[] { "Name", "IPAddress" },
unique: true);
}
}
}

View File

@ -816,7 +816,8 @@ namespace Data.Migrations.MySql
b.HasIndex("SearchableName");
b.HasIndex("Name", "IPAddress");
b.HasIndex("Name", "IPAddress")
.IsUnique();
b.ToTable("EFAlias");
});

View File

@ -1,32 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Data.Migrations.Postgresql
{
public partial class RemoveUniqueAliasIndexConstraint : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias");
migrationBuilder.CreateIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias",
columns: new[] { "Name", "IPAddress" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias");
migrationBuilder.CreateIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias",
columns: new[] { "Name", "IPAddress" },
unique: true);
}
}
}

View File

@ -836,7 +836,8 @@ namespace Data.Migrations.Postgresql
b.HasIndex("SearchableName");
b.HasIndex("Name", "IPAddress");
b.HasIndex("Name", "IPAddress")
.IsUnique();
b.ToTable("EFAlias");
});

View File

@ -1,15 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Data.Migrations.Sqlite
{
public partial class RemoveUniqueAliasIndexConstraint : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -815,7 +815,8 @@ namespace Data.Migrations.Sqlite
b.HasIndex("SearchableName");
b.HasIndex("Name", "IPAddress");
b.HasIndex("Name", "IPAddress")
.IsUnique();
b.ToTable("EFAlias");
});

View File

@ -57,11 +57,10 @@ namespace Data.Models.Client.Stats
public double MaxStrain { get; set; }
[NotMapped]
public float AverageHitOffset =>
(float) Math.Round(
HitLocations.Sum(c => c.HitOffsetAverage) /
Math.Max(1, HitLocations.Count(c => c.HitOffsetAverage > 0)), 4);
public float AverageHitOffset
{
get => (float)Math.Round(HitLocations.Sum(c => c.HitOffsetAverage) / Math.Max(1, HitLocations.Where(c => c.HitOffsetAverage > 0).Count()), 4);
}
[NotMapped]
public int SessionKills { get; set; }
[NotMapped]
@ -83,26 +82,26 @@ namespace Data.Models.Client.Stats
KillStreak = 0;
DeathStreak = 0;
LastScore = 0;
_sessionScores.Add(0);
SessionScores.Add(0);
Team = 0;
}
[NotMapped]
public int SessionScore
{
set => _sessionScores[^1] = value;
set => SessionScores[SessionScores.Count - 1] = value;
get
{
lock (_sessionScores)
lock (SessionScores)
{
return new List<int>(_sessionScores).Sum();
return new List<int>(SessionScores).Sum();
}
}
}
[NotMapped]
public int RoundScore => _sessionScores[^1];
public int RoundScore => SessionScores[SessionScores.Count - 1];
[NotMapped]
private readonly List<int> _sessionScores = new List<int> { 0 };
private readonly List<int> SessionScores = new List<int>() { 0 };
[NotMapped]
public int Team { get; set; }
[NotMapped]
@ -110,21 +109,6 @@ namespace Data.Models.Client.Stats
[NotMapped]
public double SessionSPM { get; set; }
[NotMapped]
public SemaphoreSlim ProcessingHit { get; }
[NotMapped] public MatchData MatchData { get; } = new MatchData();
}
public class MatchData
{
public int Kills { get; set; }
public int Deaths { get; set; }
public double Kdr => Deaths == 0 ? Kills : Math.Round(Kills / (double) Deaths, 2);
public void StartNewMatch()
{
Kills = 0;
Deaths = 0;
}
public SemaphoreSlim ProcessingHit { get; private set; }
}
}

View File

@ -49,7 +49,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlug
Plugins\ScriptPlugins\ParserS1x.js = Plugins\ScriptPlugins\ParserS1x.js
Plugins\ScriptPlugins\ParserCSGO.js = Plugins\ScriptPlugins\ParserCSGO.js
Plugins\ScriptPlugins\ParserCSGOSM.js = Plugins\ScriptPlugins\ParserCSGOSM.js
Plugins\ScriptPlugins\ParserPlutoniumT4COZM.js = Plugins\ScriptPlugins\ParserPlutoniumT4COZM.js
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomessageFeed", "Plugins\AutomessageFeed\AutomessageFeed.csproj", "{F5815359-CFC7-44B4-9A3B-C04BACAD5836}"

View File

@ -66,7 +66,6 @@ namespace Integrations.Source
// ignored
}
await Task.Delay(ConnectionTimeout);
_rconClient = _rconClientFactory.CreateClient(_ipEndPoint);
_authenticated = false;
_needNewSocket = false;
@ -184,4 +183,4 @@ namespace Integrations.Source
{
}
}
}
}

View File

@ -3,14 +3,14 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<LangVersion>Latest</LangVersion>
<LangVersion>7.1</LangVersion>
<Configurations>Debug;Release;Prerelease</Configurations>
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2021.11.21.1" PrivateAssets="All" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -6,11 +6,11 @@
<ApplicationIcon />
<StartupObject />
<Configurations>Debug;Release;Prerelease</Configurations>
<LangVersion>Latest</LangVersion>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2021.11.21.1" PrivateAssets="All" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -9,7 +9,7 @@
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<Version>0.1.0.0</Version>
<Configurations>Debug;Release;Prerelease</Configurations>
<LangVersion>Latest</LangVersion>
<LangVersion>7.1</LangVersion>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
@ -23,7 +23,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2021.11.21.1" PrivateAssets="All" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -17,7 +17,7 @@
@foreach (SharedLibraryCore.Dtos.ServerInfo server in ViewBag.Servers)
{
<li class="nav-item">
<a asp-controller="Radar" asp-action="Index" asp-route-serverId="@server.ID" class="nav-link @(server.ID == ViewBag.ActiveServerId ? "active": "")" aria-selected="@(server.ID == ViewBag.ActiveServerId ? "true": "false")"><color-code value="@server.Name"></color-code></a>
<a asp-controller="Radar" asp-action="Index" asp-route-serverId="@server.ID" class="nav-link @(server.ID == ViewBag.ActiveServerId ? "active": "")" aria-selected="@(server.ID == ViewBag.ActiveServerId ? "true": "false")"><color-code value="@server.Name" allow="@ViewBag.EnableColorCodes"></color-code></a>
</li>
}
</ul>
@ -467,4 +467,4 @@
})
</script>
}
}

View File

@ -11,7 +11,7 @@
<Company>Forever None</Company>
<Product>Login Plugin for IW4MAdmin</Product>
<Configurations>Debug;Release;Prerelease</Configurations>
<LangVersion>Latest</LangVersion>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@ -19,7 +19,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2021.11.21.1" PrivateAssets="All" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -12,11 +12,11 @@
<Description>Warns and kicks players for using profanity</Description>
<Copyright>2018</Copyright>
<Configurations>Debug;Release;Prerelease</Configurations>
<LangVersion>Latest</LangVersion>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2021.11.21.1" PrivateAssets="All" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -3,8 +3,8 @@ var eventParser;
var plugin = {
author: 'RaidMax, Chase',
version: 0.4,
name: 'Plutonium T4 MP Parser',
version: 0.3,
name: 'Plutonium T4 Parser',
isParser: true,
onEventAsync: function (gameEvent, server) {
@ -20,16 +20,15 @@ var plugin = {
rconParser.Configuration.CommandPrefixes.RConResponse = '\xff\xff\xff\xffprint\n';
rconParser.Configuration.GuidNumberStyle = 7; // Integer
rconParser.Configuration.DefaultRConPort = 28960;
rconParser.Configuration.OverrideDvarNameMapping.Add('fs_homepath', 'fs_localAppData');
rconParser.Configuration.DefaultInstallationDirectoryHint = '{LocalAppData}/Plutonium/storage/t4';
rconParser.Version = 'Plutonium T4';
rconParser.GameName = 5; // T4
eventParser.Configuration.GuidNumberStyle = 7; // Integer
eventParser.Configuration.GameDirectory = 'main';
eventParser.Configuration.GameDirectory = 'raw';
eventParser.Version = 'Plutonium T4';
},

View File

@ -1,43 +0,0 @@
var rconParser;
var eventParser;
var plugin = {
author: 'RaidMax',
version: 0.1,
name: 'Plutonium T4 CO-OP/Zombies Parser',
isParser: true,
onEventAsync: function (gameEvent, server) {
},
onLoadAsync: function (manager) {
rconParser = manager.GenerateDynamicRConParser(this.name);
eventParser = manager.GenerateDynamicEventParser(this.name);
rconParser.Configuration.CommandPrefixes.Kick = 'clientkick {0}';
rconParser.Configuration.CommandPrefixes.Ban = 'clientkick {0}';
rconParser.Configuration.CommandPrefixes.TempBan = 'clientkick {0}';
rconParser.Configuration.CommandPrefixes.RConResponse = '\xff\xff\xff\xffprint\n';
rconParser.Configuration.GuidNumberStyle = 7; // Integer
rconParser.Configuration.DefaultRConPort = 28960;
rconParser.Configuration.CommandPrefixes.RConGetInfo = undefined;
rconParser.Configuration.DefaultInstallationDirectoryHint = '{LocalAppData}/Plutonium/storage/t4';
rconParser.Configuration.OverrideDvarNameMapping.Add('fs_homepath', 'fs_localAppData');
rconParser.Version = 'Plutonium T4 Singleplayer';
rconParser.GameName = 5; // T4
eventParser.Configuration.GuidNumberStyle = 7; // Integer
eventParser.Configuration.GameDirectory = 'main';
eventParser.Version = 'Plutonium T4 Singleplayer';
},
onUnloadAsync: function () {
},
onTickAsync: function (server) {
}
};

View File

@ -22,7 +22,7 @@ namespace Stats.Client
private readonly IDataValueCache<EFClientStatistics, Dictionary<long, Extensions.LogParams>>
_distributionCache;
private readonly IDataValueCache<EFClientStatistics, double>
_maxZScoreCache;
@ -51,9 +51,9 @@ namespace Stats.Client
var validPlayTime = _configurationHandler.Configuration()?.TopPlayersMinPlayTime ?? 3600 * 3;
var distributions = new Dictionary<long, Extensions.LogParams>();
await LoadServers();
foreach (var serverId in _serverIds)
{
var performance = await set
@ -63,14 +63,14 @@ namespace Stats.Client
.Where(s => s.Client.Level != EFClient.Permission.Banned)
.Where(s => s.TimePlayed >= validPlayTime)
.Where(s => s.UpdatedAt >= Extensions.FifteenDaysAgo())
.Select(s => s.EloRating * 1 / 3.0 + s.Skill * 2 / 3.0).ToListAsync();
.Select(s => s.EloRating * 1/3.0 + s.Skill * 2/3.0).ToListAsync();
var distributionParams = performance.GenerateDistributionParameters();
distributions.Add(serverId, distributionParams);
}
return distributions;
}), DistributionCacheKey, Utilities.IsDevelopment ? TimeSpan.FromMinutes(5) : TimeSpan.FromHours(1));
_maxZScoreCache.SetCacheItem(async (set, token) =>
{
var validPlayTime = _configurationHandler.Configuration()?.TopPlayersMinPlayTime ?? 3600 * 3;
@ -79,16 +79,13 @@ namespace Stats.Client
.Where(AdvancedClientStatsResourceQueryHelper.GetRankingFunc(validPlayTime))
.Where(s => s.Skill > 0)
.Where(s => s.EloRating > 0)
.GroupBy(stat => stat.ClientId)
.Select(group =>
group.Sum(stat => stat.ZScore * stat.TimePlayed) / group.Sum(stat => stat.TimePlayed))
.MaxAsync(avgZScore => (double?) avgZScore, token);
.MaxAsync(s => (double?)s.ZScore, token);
return zScore ?? 0;
}, MaxZScoreCacheKey, Utilities.IsDevelopment ? TimeSpan.FromMinutes(5) : TimeSpan.FromMinutes(30));
await _distributionCache.GetCacheItem(DistributionCacheKey);
await _maxZScoreCache.GetCacheItem(MaxZScoreCacheKey);
await _maxZScoreCache.GetCacheItem(MaxZScoreCacheKey);
/*foreach (var serverId in _serverIds)
{
await using var ctx = _contextFactory.CreateContext(enableTracking: true);
@ -141,7 +138,6 @@ namespace Stats.Client
{
return 0.0;
}
var zScore = (Math.Log(value) - sdParams.Mean) / sdParams.Sigma;
return zScore;
}
@ -149,7 +145,7 @@ namespace Stats.Client
public async Task<double?> GetRatingForZScore(double? value)
{
var maxZScore = await _maxZScoreCache.GetCacheItem(MaxZScoreCacheKey);
return maxZScore == 0 ? null : value.GetRatingForZScore(maxZScore);
return maxZScore == 0 ? 0 : value.GetRatingForZScore(maxZScore);
}
}
}
}

View File

@ -19,10 +19,7 @@ using Data.Models.Client;
using Data.Models.Client.Stats;
using Data.Models.Server;
using Humanizer.Localisation;
using Microsoft.Data.Sqlite;
using Microsoft.Extensions.Logging;
using MySql.Data.MySqlClient;
using Npgsql;
using Stats.Client.Abstractions;
using Stats.Config;
using Stats.Helpers;
@ -121,7 +118,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
{
return (ranking) => ranking.ServerId == serverId
&& ranking.Client.Level != Data.Models.Client.EFClient.Permission.Banned
&& ranking.CreatedDateTime >= Extensions.FifteenDaysAgo()
&& ranking.Client.LastConnection >= Extensions.FifteenDaysAgo()
&& ranking.ZScore != null
&& ranking.PerformanceMetric != null
&& ranking.Newest
@ -435,12 +432,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
return null;
}
if (pl.ClientId <= 0)
{
_log.LogWarning("Stats for {Client} are not yet initialized", pl.ToString());
return null;
}
// get the client's stats from the database if it exists, otherwise create and attach a new one
// if this fails we want to throw an exception
@ -520,15 +511,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
return clientStats;
}
catch (DbUpdateException updateException) when (
updateException.InnerException is PostgresException {SqlState: "23503"}
|| updateException.InnerException is SqliteException {SqliteErrorCode: 787}
|| updateException.InnerException is MySqlException {SqlState: "23503"})
{
_log.LogWarning("Trying to add {Client} to stats before they have been added to the database",
pl.ToString());
}
catch (Exception ex)
{
_log.LogError(ex, "Could not add client to stats {@client}", pl.ToString());
@ -671,12 +653,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
var clientDetection = attacker.GetAdditionalProperty<Detection>(CLIENT_DETECTIONS_KEY);
var clientStats = attacker.GetAdditionalProperty<EFClientStatistics>(CLIENT_STATS_KEY);
if (clientDetection == null || clientStats?.ClientId == null)
{
_log.LogWarning("Client stats state for {Client} is not yet initialized", attacker.ToString());
return;
}
waiter = clientStats.ProcessingHit;
await waiter.WaitAsync(Utilities.DefaultCommandTimeout, Plugin.ServerManager.CancellationToken);
@ -895,7 +871,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
public async Task AddStandardKill(EFClient attacker, EFClient victim)
{
var serverId = GetIdForServer(attacker.CurrentServer);
long serverId = GetIdForServer(attacker.CurrentServer);
var attackerStats = attacker.GetAdditionalProperty<EFClientStatistics>(CLIENT_STATS_KEY);
var victimStats = victim.GetAdditionalProperty<EFClientStatistics>(CLIENT_STATS_KEY);
@ -903,18 +879,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
// update the total stats
_servers[serverId].ServerStatistics.TotalKills += 1;
if (attackerStats == null)
{
_log.LogWarning("Stats for {Client} are not yet initialized", attacker.ToString());
return;
}
if (victimStats == null)
{
_log.LogWarning("Stats for {Client} are not yet initialized", victim.ToString());
return;
}
// this happens when the round has changed
if (attackerStats.SessionScore == 0)
{
@ -973,7 +937,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
// update their performance
if ((DateTime.UtcNow - attackerStats.LastStatHistoryUpdate).TotalMinutes >=
(Utilities.IsDevelopment ? 0.5 : _configHandler.Configuration().EnableAdvancedMetrics ? 5.0 : 2.5))
(Utilities.IsDevelopment ? 0.5 : _configHandler.Configuration().EnableAdvancedMetrics ? 10.0 : 2.5))
{
try
{
@ -1190,17 +1154,16 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
public async Task UpdateHistoricalRanking(int clientId, EFClientStatistics clientStats, long serverId)
{
await using var context = _contextFactory.CreateContext();
var minPlayTime = _configHandler.Configuration().TopPlayersMinPlayTime;
var performances = await context.Set<EFClientStatistics>()
.AsNoTracking()
.Where(stat => stat.ClientId == clientId)
.Where(stat => stat.ServerId != serverId) // ignore the one we're currently tracking
.Where(stats => stats.UpdatedAt >= Extensions.FifteenDaysAgo())
.Where(stats => stats.TimePlayed >= minPlayTime)
.Where(stats => stats.TimePlayed >= _configHandler.Configuration().TopPlayersMinPlayTime)
.ToListAsync();
if (clientStats.TimePlayed >= minPlayTime)
if (clientStats.TimePlayed >= _configHandler.Configuration().TopPlayersMinPlayTime)
{
clientStats.ZScore = await _serverDistributionCalculator.GetZScoreForServer(serverId,
clientStats.Performance);
@ -1211,7 +1174,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
_configHandler.Configuration().TopPlayersMinPlayTime, clientStats.ZScore, serverId))
.CountAsync();
var serverRankingSnapshot = new EFClientRankingHistory
var serverRankingSnapshot = new EFClientRankingHistory()
{
ClientId = clientId,
ServerId = serverId,
@ -1228,35 +1191,27 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
performances.Add(clientStats);
}
if (performances.Any(performance => performance.TimePlayed >= minPlayTime))
if (performances.Any(performance => performance.TimePlayed >= _configHandler.Configuration().TopPlayersMinPlayTime))
{
var aggregateZScore = performances.WeightValueByPlaytime(nameof(EFClientStatistics.ZScore), minPlayTime);
var aggregateZScore = performances.WeightValueByPlaytime(nameof(EFClientStatistics.ZScore), _configHandler.Configuration().TopPlayersMinPlayTime);
int? aggregateRanking = await context.Set<EFClientStatistics>()
.Where(stat => stat.ClientId != clientId)
.Where(AdvancedClientStatsResourceQueryHelper.GetRankingFunc(minPlayTime))
.Where(AdvancedClientStatsResourceQueryHelper.GetRankingFunc(_configHandler.Configuration()
.TopPlayersMinPlayTime))
.GroupBy(stat => stat.ClientId)
.Where(group =>
group.Sum(stat => stat.ZScore * stat.TimePlayed) / group.Sum(stat => stat.TimePlayed) >
aggregateZScore)
.Select(c => c.Key)
.CountAsync();
var newPerformanceMetric = await _serverDistributionCalculator.GetRatingForZScore(aggregateZScore);
if (newPerformanceMetric == null)
{
_log.LogWarning("Could not determine performance metric for {Client} {AggregateZScore}",
clientStats.Client?.ToString(), aggregateZScore);
return;
}
var aggregateRankingSnapshot = new EFClientRankingHistory
var aggregateRankingSnapshot = new EFClientRankingHistory()
{
ClientId = clientId,
ZScore = aggregateZScore,
Ranking = aggregateRanking,
PerformanceMetric = newPerformanceMetric,
PerformanceMetric = await _serverDistributionCalculator.GetRatingForZScore(aggregateZScore),
Newest = true,
};
@ -1310,14 +1265,12 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
if (!suicide)
{
attackerStats.Kills += 1;
attackerStats.MatchData.Kills += 1;
attackerStats.SessionKills += 1;
attackerStats.KillStreak += 1;
attackerStats.DeathStreak = 0;
}
victimStats.Deaths += 1;
victimStats.MatchData.Deaths += 1;
victimStats.SessionDeaths += 1;
victimStats.DeathStreak += 1;
victimStats.KillStreak = 0;
@ -1467,7 +1420,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
{
session.stat?.StartNewSession();
session.detection?.OnMapChange();
session.stat?.MatchData?.StartNewMatch();
}
}
@ -1577,4 +1529,4 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
return serverId.Value;
}
}
}
}

View File

@ -1,4 +1,5 @@
using IW4MAdmin.Plugins.Stats.Helpers;
using IW4MAdmin.Plugins.Stats.Config;
using IW4MAdmin.Plugins.Stats.Helpers;
using Microsoft.EntityFrameworkCore;
using SharedLibraryCore;
using SharedLibraryCore.Dtos.Meta.Responses;
@ -14,7 +15,9 @@ using Data.Abstractions;
using Data.Models.Client;
using Data.Models.Client.Stats;
using Data.Models.Server;
using Humanizer;
using Microsoft.Extensions.Logging;
using SharedLibraryCore.Commands;
using IW4MAdmin.Plugins.Stats.Client.Abstractions;
using Stats.Client.Abstractions;
using Stats.Config;

View File

@ -12,12 +12,12 @@
<Description>Client Statistics Plugin for IW4MAdmin</Description>
<Copyright>2018</Copyright>
<Configurations>Debug;Release;Prerelease</Configurations>
<LangVersion>Latest</LangVersion>
<LangVersion>8.0</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2021.11.21.1" PrivateAssets="All" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -20,7 +20,7 @@
</Target>
<ItemGroup>
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2021.11.21.1" PrivateAssets="All" />
</ItemGroup>
</Project>

View File

@ -62,7 +62,7 @@ namespace SharedLibraryCore
/// <summary>
/// Helper property to provide the syntax of the command
/// </summary>
public string Syntax => $"{_translationLookup["COMMAND_HELP_SYNTAX"]} {_config.CommandPrefix ?? "!"}{Alias} {string.Join(" ", Arguments.Select(a => $"<{(a.Required ? "" : _translationLookup["COMMAND_HELP_OPTIONAL"] + " ")}{a.Name}>"))}";
public string Syntax => $"{_translationLookup["COMMAND_HELP_SYNTAX"]} {_config.CommandPrefix}{Alias} {string.Join(" ", Arguments.Select(a => $"<{(a.Required ? "" : _translationLookup["COMMAND_HELP_OPTIONAL"] + " ")}{a.Name}>"))}";
/// <summary>
/// Alternate name for this command to be executed by

View File

@ -153,7 +153,7 @@ namespace SharedLibraryCore.Services
{
_logger.LogDebug("[{Method}] creating new Link and Alias for {Entity}", nameof(HandleNewCreate), entity.ToString());
var link = new EFAliasLink();
var alias = new EFAlias
var alias = new EFAlias()
{
Name = entity.Name,
SearchableName = entity.Name.StripColors().ToLower(),
@ -167,18 +167,9 @@ namespace SharedLibraryCore.Services
else
{
_logger.LogDebug("[{Method}] associating new GUID {Guid} with new exact alias match with linkId {LinkId} for {Entity}",
nameof(HandleNewCreate), entity.GuidString, existingAlias.LinkId, entity.ToString());
var alias = new EFAlias
{
Name = existingAlias.Name,
SearchableName = entity.Name.StripColors().ToLower(),
DateAdded = DateTime.UtcNow,
IPAddress = entity.IPAddress,
LinkId = existingAlias.LinkId
};
client.CurrentAlias = alias;
_logger.LogDebug("[{Method}] associating new GUID {Guid} with existing alias id {aliasId} for {Entity}",
nameof(HandleNewCreate), entity.GuidString, existingAlias.AliasId, entity.ToString());
client.CurrentAliasId = existingAlias.AliasId;
client.AliasLinkId = existingAlias.LinkId;
}
@ -347,7 +338,7 @@ namespace SharedLibraryCore.Services
return;
}
if (existingExactAlias != null && entity.AliasLinkId == existingExactAlias.LinkId)
if (existingExactAlias != null)
{
entity.CurrentAlias = existingExactAlias;
entity.CurrentAliasId = existingExactAlias.AliasId;

View File

@ -1,68 +1,56 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PackageId>RaidMax.IW4MAdmin.SharedLibraryCore</PackageId>
<Version>2022.01.20.1</Version>
<Authors>RaidMax</Authors>
<Company>Forever None</Company>
<Configurations>Debug;Release;Prerelease</Configurations>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<LangVersion>8.0</LangVersion>
<PackageTags>IW4MAdmin</PackageTags>
<RepositoryUrl>https://github.com/RaidMax/IW4M-Admin/</RepositoryUrl>
<PackageProjectUrl>https://www.raidmax.org/IW4MAdmin/</PackageProjectUrl>
<Copyright>2022</Copyright>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IsPackable>true</IsPackable>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Description>Shared Library for IW4MAdmin</Description>
<PackageVersion>2022.01.20.1</PackageVersion>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PackageId>RaidMax.IW4MAdmin.SharedLibraryCore</PackageId>
<Version>2021.11.21.1</Version>
<Authors>RaidMax</Authors>
<Company>Forever None</Company>
<Configurations>Debug;Release;Prerelease</Configurations>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<LangVersion>8.0</LangVersion>
<PackageTags>IW4MAdmin</PackageTags>
<RepositoryUrl>https://github.com/RaidMax/IW4M-Admin/</RepositoryUrl>
<PackageProjectUrl>https://www.raidmax.org/IW4MAdmin/</PackageProjectUrl>
<Copyright>2021</Copyright>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IsPackable>true</IsPackable>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Description>Shared Library for IW4MAdmin</Description>
<PackageVersion>2021.11.21.1</PackageVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Prerelease|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="9.3.0"/>
<PackageReference Include="Humanizer.Core" Version="2.8.26"/>
<PackageReference Include="Humanizer.Core.ru" Version="2.8.26"/>
<PackageReference Include="Humanizer.Core.de" Version="2.8.26"/>
<PackageReference Include="Humanizer.Core.es" Version="2.8.26"/>
<PackageReference Include="Humanizer.Core.pt" Version="2.8.26"/>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.10"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.10"/>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.10"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.10"/>
<PackageReference Include="Microsoft.Extensions.Localization" Version="3.1.10"/>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.10"/>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.10"/>
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.10"/>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0"/>
<PackageReference Include="SimpleCrypto.NetCore" Version="1.0.0"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Data\Data.csproj"/>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="if not exist &quot;$(ProjectDir)..\BUILD&quot; (&#xD;&#xA;if $(ConfigurationName) == Debug (&#xD;&#xA;md &quot;$(ProjectDir)..\BUILD&quot;&#xD;&#xA;)&#xD;&#xA;)&#xD;&#xA;if not exist &quot;$(ProjectDir)..\BUILD\Plugins&quot; (&#xD;&#xA;if $(ConfigurationName) == Debug (&#xD;&#xA;md &quot;$(ProjectDir)..\BUILD\Plugins&quot;&#xD;&#xA;)&#xD;&#xA;)"/>
</Target>
<PropertyGroup>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
<Target DependsOnTargets="BuildOnlySettings;ResolveReferences" Name="CopyProjectReferencesToPackage">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))"/>
</ItemGroup>
</Target>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Prerelease|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="9.3.0" />
<PackageReference Include="Humanizer.Core" Version="2.8.26" />
<PackageReference Include="Humanizer.Core.ru" Version="2.8.26" />
<PackageReference Include="Humanizer.Core.de" Version="2.8.26" />
<PackageReference Include="Humanizer.Core.es" Version="2.8.26" />
<PackageReference Include="Humanizer.Core.pt" Version="2.8.26" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.10" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="RaidMax.IW4MAdmin.Data" Version="1.0.9" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="SimpleCrypto.NetCore" Version="1.0.0" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="if not exist &quot;$(ProjectDir)..\BUILD&quot; (&#xD;&#xA;if $(ConfigurationName) == Debug (&#xD;&#xA;md &quot;$(ProjectDir)..\BUILD&quot;&#xD;&#xA;)&#xD;&#xA;)&#xD;&#xA;if not exist &quot;$(ProjectDir)..\BUILD\Plugins&quot; (&#xD;&#xA;if $(ConfigurationName) == Debug (&#xD;&#xA;md &quot;$(ProjectDir)..\BUILD\Plugins&quot;&#xD;&#xA;)&#xD;&#xA;)" />
</Target>
</Project>

View File

@ -1,35 +1,28 @@
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Razor.TagHelpers;
using SharedLibraryCore.Configuration;
namespace SharedLibraryCore
{
[HtmlTargetElement("color-code")]
public class ColorCode : TagHelper
{
public ColorCode(ApplicationConfiguration appConfig)
{
_allow = appConfig?.EnableColorCodes ?? false;
}
public string Value { get; set; }
private readonly bool _allow;
public bool Allow { get; set; } = false;
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.TagName = "ColorCode";
output.TagMode = TagMode.StartTagAndEndTag;
if (_allow)
if (Allow)
{
var matches = Regex.Matches(Value, @"\^([0-9]|\:)([^\^]*)");
foreach (Match match in matches)
{
var colorCode = match.Groups[1].ToString().Last();
output.PreContent.AppendHtml(
$"<span class='text-color-code-{(colorCode >= 48 && colorCode <= 57 ? colorCode.ToString() : ((int) colorCode).ToString())}'>");
char colorCode = match.Groups[1].ToString().Last();
output.PreContent.AppendHtml($"<span class='text-color-code-{(colorCode >= 48 && colorCode <= 57 ? colorCode.ToString() : ((int)colorCode).ToString())}'>");
output.PreContent.Append(match.Groups[2].ToString());
output.PreContent.AppendHtml("</span>");
}

View File

@ -114,7 +114,7 @@ namespace WebfrontCore.Controllers
ViewBag.Title += " " + Localization["WEBFRONT_CLIENT_PROFILE_TITLE"];
ViewBag.Description = $"Client information for {strippedName}";
ViewBag.Keywords = $"IW4MAdmin, client, profile, {strippedName}";
ViewBag.UseNewStats = _configurationHandler.Configuration()?.EnableAdvancedMetrics ?? true;
ViewBag.UseNewStats = _configurationHandler.Configuration().EnableAdvancedMetrics;
return View("Profile/Index", clientDto);
}

View File

@ -1,20 +1,20 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore;
using SharedLibraryCore.Dtos;
using SharedLibraryCore.Interfaces;
using System.Linq;
using Data.Models.Client.Stats;
using IW4MAdmin.Plugins.Stats.Helpers;
using WebfrontCore.ViewModels;
using SharedLibraryCore.Configuration;
namespace WebfrontCore.Controllers
{
public class ServerController : BaseController
{
public ServerController(IManager manager) : base(manager)
private readonly DefaultSettings _defaultSettings;
public ServerController(IManager manager, DefaultSettings defaultSettings) : base(manager)
{
_defaultSettings = defaultSettings;
}
[HttpGet]
@ -36,75 +36,21 @@ namespace WebfrontCore.Controllers
Map = s.CurrentMap.Alias,
ClientCount = s.Clients.Count(client => client != null),
MaxClients = s.MaxClients,
GameType = s.GametypeName,
GameType = s.GametypeName,
Players = s.GetClientsAsList()
.Select(p => new PlayerInfo
{
Name = p.Name,
ClientId = p.ClientId,
Level = p.Level.ToLocalizedLevelName(),
LevelInt = (int) p.Level,
ZScore = p.GetAdditionalProperty<EFClientStatistics>(IW4MAdmin.Plugins.Stats.Helpers.StatManager
.CLIENT_STATS_KEY)?.ZScore
}).ToList(),
.Select(p => new PlayerInfo
{
Name = p.Name,
ClientId = p.ClientId,
Level = p.Level.ToLocalizedLevelName(),
LevelInt = (int)p.Level,
ZScore = p.GetAdditionalProperty<EFClientStatistics>(IW4MAdmin.Plugins.Stats.Helpers.StatManager.CLIENT_STATS_KEY)?.ZScore
}).ToList(),
ChatHistory = s.ChatHistory.ToList(),
PlayerHistory = s.ClientHistory.ToArray(),
IsPasswordProtected = !string.IsNullOrEmpty(s.GamePassword)
};
return PartialView("_ClientActivity", serverInfo);
}
[HttpGet]
public ActionResult Scoreboard()
{
ViewBag.Title = Localization["WEBFRONT_TITLE_SCOREBOARD"];
return View(ProjectScoreboard(Manager.GetServers(), null, true));
}
[HttpGet("[controller]/{id}/scoreboard")]
public ActionResult Scoreboard(long id, [FromQuery]string order = null, [FromQuery] bool down = true)
{
var server = Manager.GetServers().FirstOrDefault(srv => srv.EndPoint == id);
if (server == null)
{
return NotFound();
}
return View("_Scoreboard", ProjectScoreboard(new[] {server}, order, down).First());
}
private static IEnumerable<ScoreboardInfo> ProjectScoreboard(IEnumerable<Server> servers, string order,
bool down)
{
return servers.Select(server => new ScoreboardInfo
{
OrderByKey = order,
ShouldOrderDescending = down,
MapName = server.CurrentMap.ToString(),
ServerName = server.Hostname,
ServerId = server.EndPoint,
ClientInfo = server.GetClientsAsList().Select(client =>
new
{
stats = client.GetAdditionalProperty<EFClientStatistics>(StatManager.CLIENT_STATS_KEY),
client
})
.Select(clientData => new ClientScoreboardInfo
{
ClientName = clientData.client.Name,
ClientId = clientData.client.ClientId,
Score = Math.Max(clientData.client.Score, clientData.stats?.RoundScore ?? 0),
Ping = clientData.client.Ping,
Kills = clientData.stats?.MatchData?.Kills,
Deaths = clientData.stats?.MatchData?.Deaths,
ScorePerMinute = clientData.stats?.SessionSPM,
Kdr = clientData.stats?.MatchData?.Kdr,
ZScore = clientData.stats?.ZScore
})
.ToList()
}).ToList();
}
}
}

View File

@ -1,6 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using IW4MAdmin.Plugins.Stats;
using IW4MAdmin.Plugins.Stats.Config;
using IW4MAdmin.Plugins.Stats.Helpers;
using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore.Interfaces;
@ -32,11 +33,11 @@ namespace WebfrontCore.ViewComponents
}
ViewBag.UseNewStats = _configurationHandler.Configuration()?.EnableAdvancedMetrics ?? true;
ViewBag.UseNewStats = _configurationHandler.Configuration().EnableAdvancedMetrics;
return View("~/Views/Client/Statistics/Components/TopPlayers/_List.cshtml",
ViewBag.UseNewStats
_configurationHandler.Configuration().EnableAdvancedMetrics
? await Plugin.Manager.GetNewTopStats(offset, count, serverId)
: await Plugin.Manager.GetTopStats(offset, count, serverId));
}
}
}
}

View File

@ -1,28 +0,0 @@
using System.Collections.Generic;
namespace WebfrontCore.ViewModels
{
public class ScoreboardInfo
{
public string ServerName { get; set; }
public long ServerId { get; set; }
public string MapName { get; set; }
public string OrderByKey { get; set; }
public bool ShouldOrderDescending { get; set; }
public List<ClientScoreboardInfo> ClientInfo { get; set; }
}
public class ClientScoreboardInfo
{
public string ClientName { get; set; }
public long ClientId { get; set; }
public int Score { get; set; }
public int Ping { get; set; }
public int? Kills { get; set; }
public int? Deaths { get; set; }
public double? ScorePerMinute { get; set; }
public double? Kdr { get; set; }
public double? ZScore { get; set; }
}
}

View File

@ -18,7 +18,7 @@
@if (!string.IsNullOrWhiteSpace(Model.CommunityInformation.Name))
{
<h2 class="mb-4 p-0 col-12 text-center text-md-left">
<color-code value="@Model.CommunityInformation.Name"></color-code>
<color-code value="@Model.CommunityInformation.Name" allow="@ViewBag.EnableColorCodes"></color-code>
</h2>
}
@ -26,7 +26,7 @@
{
<div class="p-4 bg-dark border border-primary mb-4 text-white-50 col-12">
<h4 class="text-primary">@ViewBag.Localization["WEBFRONT_ABOUT_TITLE"]</h4>
<color-code value="@Model.CommunityInformation.Description"></color-code>
<color-code value="@Model.CommunityInformation.Description" allow="@ViewBag.EnableColorCodes"></color-code>
<div class="mt-3">
@foreach (var social in Model.CommunityInformation.SocialAccounts ?? new SocialAccountConfiguration[0])
{
@ -66,16 +66,16 @@
var start = 1;
<div class="col-12 bg-dark p-4 border border-primary mb-4 col-12">
<div class="text-primary h4">
<color-code value="@serverName"></color-code>
<color-code value="@serverName" allow="@ViewBag.EnableColorCodes"></color-code>
</div>
@foreach (var rule in rules)
{
<div class="text-white-50">
<span class="text-white">@start.</span>
<color-code value="@rule"></color-code>
<color-code value="@rule" allow="@ViewBag.EnableColorCodes"></color-code>
</div>
start++;
}
</div>
}
</div>
</div>

View File

@ -17,7 +17,7 @@
<th scope="row" class="bg-primary">@loc["WEBFRONT_PENALTY_TEMPLATE_ADMIN"]</th>
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@info.OriginId" class="link-inverse">
<color-code value="@info.OriginName"></color-code>
<color-code value="@info.OriginName" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</td>
</tr>
@ -27,7 +27,7 @@
@if (info.TargetId != null)
{
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@info.TargetId" class="link-inverse">
<color-code value="@info.TargetName"></color-code>
<color-code value="@info.TargetName" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
}
else
@ -68,14 +68,14 @@
</td>
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@info.OriginId" class="link-inverse">
<color-code value="@info.OriginName"></color-code>
<color-code value="@info.OriginName" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</td>
<td>
@if (info.TargetId != null)
{
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@info.TargetId" class="link-inverse">
<color-code value="@info.TargetName"></color-code>
<color-code value="@info.TargetName" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
}
else
@ -96,4 +96,4 @@
@info.When.ToString()
</td>
</tr>
}
}

View File

@ -17,7 +17,7 @@
<div class="row pt-2 pb-2 bg-dark">
<div class="col-5">
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@client.ClientId">
<color-code value="@client.Name"></color-code>
<color-code value="@client.Name" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</div>
@if (!ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy)
@ -45,7 +45,7 @@
<div class="col-7 bg-dark border-bottom">
<div class="p-2">
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@client.ClientId" class="link-inverse">
<color-code value="@client.Name"></color-code>
<color-code value="@client.Name" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</div>
@if (!ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy)
@ -59,4 +59,4 @@
<div class="p-2 text-white-50">@client.LastConnectionText</div>
</div>
}
</div>
</div>

View File

@ -7,21 +7,21 @@
<tr class="d-none d-lg-table-row">
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@message.ClientId" class="link-inverse">
<color-code value="@message.ClientName"></color-code>
<color-code value="@message.ClientName" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</td>
<td class="text-light w-50 text-break">
@if (message.IsHidden && !ViewBag.Authorized)
{
<color-code value="@SharedLibraryCore.Utilities.FormatExt(ViewBag.Localization["WEBFRONT_CLIENT_META_CHAT_HIDDEN"], message.HiddenMessage)"></color-code>
<color-code value="@SharedLibraryCore.Utilities.FormatExt(ViewBag.Localization["WEBFRONT_CLIENT_META_CHAT_HIDDEN"], message.HiddenMessage)" allow="@ViewBag.EnableColorCodes"></color-code>
}
else
{
<color-code value="@message.Message"></color-code>
<color-code value="@message.Message" allow="@ViewBag.EnableColorCodes"></color-code>
}
</td>
<td class="text-light">
<color-code value="@(message.ServerName ?? "--")"></color-code>
<color-code value="@(message.ServerName ?? "--")" allow="@ViewBag.EnableColorCodes"></color-code>
</td>
<td class="text-right text-light">
@message.When
@ -33,7 +33,7 @@
<th scope="row" class="bg-primary">@ViewBag.Localization["WEBFRONT_PENALTY_TEMPLATE_ADMIN"]</th>
<td class="text-light">
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@message.ClientId" class="link-inverse">
<color-code value="@message.ClientName"></color-code>
<color-code value="@message.ClientName" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</td>
</tr>
@ -43,11 +43,11 @@
<td class="text-light">
@if (message.IsHidden && !ViewBag.Authorized)
{
<color-code value="@SharedLibraryCore.Utilities.FormatExt(ViewBag.Localization["WEBFRONT_CLIENT_META_CHAT_HIDDEN"], message.HiddenMessage)"></color-code>
<color-code value="@SharedLibraryCore.Utilities.FormatExt(ViewBag.Localization["WEBFRONT_CLIENT_META_CHAT_HIDDEN"], message.HiddenMessage)" allow="@ViewBag.EnableColorCodes"></color-code>
}
else
{
<color-code value="@message.Message"></color-code>
<color-code value="@message.Message" allow="@ViewBag.EnableColorCodes"></color-code>
}
</td>
</tr>
@ -55,7 +55,7 @@
<tr class="d-table-row d-lg-none bg-dark">
<th scope="row" class="bg-primary">@ViewBag.Localization["WEBFRONT_STATS_MESSAGE_SERVER_NAME"]</th>
<td class="text-light">
<color-code value="@(message.ServerName ?? "--")"></color-code>
<color-code value="@(message.ServerName ?? "--")" allow="@ViewBag.EnableColorCodes"></color-code>
</td>
</tr>
@ -65,4 +65,4 @@
@message.When
</td>
</tr>
}
}

View File

@ -14,11 +14,11 @@
@foreach (var client in Model[key])
{
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@client.ClientId">
<color-code value="@client.Name"></color-code>
<color-code value="@client.Name" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
<br />
}
</div>
}
}
</div>
</div>

View File

@ -25,7 +25,7 @@
<div class="w-50 d-block d-lg-inline-flex flex-column flex-fill text-center text-lg-left pb-3 pb-lg-0 pt-3 pt-lg-0 pl-3 pr-3 ml-auto mr-auto" style="overflow-wrap: anywhere">
<div class="mt-n2 d-block d-lg-inline-flex @(ViewBag.Authorized ? "" : "flex-fill")">
<div id="profile_name" class="client-name h1 mb-0">
<color-code value="@Model.Name"></color-code>
<color-code value="@Model.Name" allow="@ViewBag.EnableColorCodes"></color-code>
</div>
@if (ViewBag.Authorized)
{
@ -50,7 +50,7 @@
@foreach (var alias in Model.Aliases)
{
<div>
<color-code value="@alias"></color-code>
<color-code value="@alias" allow="@ViewBag.EnableColorCodes"></color-code>
</div>
}
@ -196,4 +196,4 @@
<script type="text/javascript" src="~/js/profile.js"></script>
</environment>
<script>initLoader('/Client/Meta/@Model.ClientId', '#profile_events', 30, 30, [{ 'name': 'metaFilterType', 'value': '@Model.MetaFilterType' }]);</script>
}
}

View File

@ -18,7 +18,7 @@
{
<span class="text-highlight">
<a class="link-inverse" href="@Model.OffenderClientId">
<color-code value="@Model.OffenderName"></color-code>
<color-code value="@Model.OffenderName" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</span>
}
@ -33,7 +33,7 @@
}
else
{
<color-code value="@Model.Offense"></color-code>
<color-code value="@Model.Offense" allow="@ViewBag.EnableColorCodes"></color-code>
}
</span>

View File

@ -15,7 +15,7 @@
break;
case "server":
<span class="text-white">
<color-code value="@Model.ServerName"></color-code>
<color-code value="@Model.ServerName" allow="@ViewBag.EnableColorCodes"></color-code>
</span>
break;
}
@ -25,4 +25,4 @@
{
<span class="text-muted">@token.MatchValue</span>
}
}
}

View File

@ -22,7 +22,7 @@
{
if (result.IsInterpolation)
{
<span class="profile-meta-value text-primary"><color-code value="@meta.Value"></color-code></span>
<span class="profile-meta-value text-primary"><color-code value="@meta.Value" allow="@ViewBag.EnableColorCodes"></color-code></span>
}
else
@ -34,10 +34,10 @@
else
{
<span class="profile-meta-value text-primary"><color-code value="@meta.Value"></color-code></span>
<span class="profile-meta-value text-primary"><color-code value="@meta.Value" allow="@ViewBag.EnableColorCodes"></color-code></span>
<span class="profile-meta-title text-muted"> @meta.Key</span>
}
</div>
}
</div>
}
}

View File

@ -11,12 +11,12 @@
@if (Model.IsHidden && !ViewBag.Authorized)
{
<color-code value="@SharedLibraryCore.Utilities.FormatExt(ViewBag.Localization["WEBFRONT_CLIENT_META_CHAT_HIDDEN"], Model.HiddenMessage)"></color-code>
<color-code value="@SharedLibraryCore.Utilities.FormatExt(ViewBag.Localization["WEBFRONT_CLIENT_META_CHAT_HIDDEN"], Model.HiddenMessage)" allow="@ViewBag.EnableColorCodes"></color-code>
}
else
{
<color-code value="@Model.Message"></color-code>
<color-code value="@Model.Message" allow="@ViewBag.EnableColorCodes"></color-code>
}
</span>
</span>
</span>

View File

@ -19,7 +19,7 @@
{
<span class="text-highlight">
<a class="link-inverse" href="@Model.PunisherClientId">
<color-code value="@Model.PunisherName"></color-code>
<color-code value="@Model.PunisherName" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</span>
}
@ -34,7 +34,7 @@
}
else
{
<color-code value="@Model.Offense"></color-code>
<color-code value="@Model.Offense" allow="@ViewBag.EnableColorCodes"></color-code>
}
</span>
@ -65,7 +65,7 @@
else
{
<a class="link-inverse" href="@Model.OffenderClientId">
<color-code value="@Model.OffenderName"></color-code>
<color-code value="@Model.OffenderName" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
}
}

View File

@ -13,7 +13,7 @@
break;
case "alias":
<span class="text-white">
<color-code value="@Model.Name"></color-code>
<color-code value="@Model.Name" allow="@ViewBag.EnableColorCodes"></color-code>
[@Model.IPAddress]
</span>
break;

View File

@ -7,7 +7,7 @@
{
<li class="nav-item ">
<a class="nav-link top-players-link" href="#server_@server.ID" role="tab" data-toggle="tab" aria-selected="false" data-serverid="@server.ID">
<color-code value="@server.Name"></color-code>
<color-code value="@server.Name" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</li>
}

View File

@ -9,7 +9,7 @@
<th scope="row" class="bg-primary">@loc["WEBFRONT_PENALTY_TEMPLATE_NAME"]</th>
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@Model.OffenderId" class="link-inverse">
<color-code value="@Model.OffenderName"></color-code>
<color-code value="@Model.OffenderName" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</td>
</tr>
@ -24,7 +24,7 @@
<tr class="d-table-row d-lg-none bg-dark">
<th scope="row" class="bg-primary">@loc["WEBFRONT_PENALTY_TEMPLATE_OFFENSE"]</th>
<td class="text-light">
<color-code value="@($"{Model.Offense}{(ViewBag.Authorized ? Model.AdditionalPenaltyInformation : "")}")"></color-code>
<color-code value="@($"{Model.Offense}{(ViewBag.Authorized ? Model.AdditionalPenaltyInformation : "")}")" allow="@ViewBag.EnableColorCodes"></color-code>
</td>
</tr>
@ -59,14 +59,14 @@
<tr class="d-none d-lg-table-row">
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@Model.OffenderId" class="link-inverse">
<color-code value="@Model.OffenderName"></color-code>
<color-code value="@Model.OffenderName" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</td>
<td class="penalties-color-@Model.PenaltyTypeText.ToLower()">
@Model.PenaltyType
</td>
<td class="text-light w-50">
<color-code value="@($"{Model.Offense}{(ViewBag.Authorized ? Model.AdditionalPenaltyInformation : "")}")"></color-code>
<color-code value="@($"{Model.Offense}{(ViewBag.Authorized ? Model.AdditionalPenaltyInformation : "")}")" allow="@ViewBag.EnableColorCodes"></color-code>
</td>
<td>
@Html.ActionLink(SharedLibraryCore.Utilities.StripColors(Model.PunisherName), "ProfileAsync",
@ -88,4 +88,4 @@
}
}
</td>
</tr>
</tr>

View File

@ -1,30 +0,0 @@
@model IEnumerable<WebfrontCore.ViewModels.ScoreboardInfo>
<ul class="nav nav-tabs border-top border-bottom nav-fill row" role="tablist" id="scoreboard_servers">
@{ var i = 0; }
@foreach (var server in Model)
{
<li class="nav-item">
<a class="nav-link" href="#server_@server.ServerId" role="tab" data-toggle="tab" id="server_@(server.ServerId)_nav" data-serverid="@server.ServerId">
<color-code value="@server.ServerName"></color-code>
</a>
</li>
i++;
}
</ul>
<div class="tab-content border-bottom row">
@{ i = 0; }
@foreach (var server in Model)
{
<div role="tabpanel" class="scoreboard-container tab-pane striped flex-fill" id="server_@server.ServerId" data-server-id="@server.ServerId">
@await Html.PartialAsync("_Scoreboard", server)
</div>
i++;
}
</div>
@section scripts {
<environment include="Development">
<script type="text/javascript" src="~/js/scoreboard.js" defer="defer"></script>
</environment>
}

View File

@ -21,24 +21,24 @@
{
<span class="text-light">
<span class="oi oi-account-login mr-2 text-success"> </span>
<color-code value="@Model.ChatHistory[i].Name"></color-code>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</span><br />
}
if (Model.ChatHistory[i].Message == "DISCONNECTED")
{
<span class="text-light">
<span class="oi oi-account-logout mr-2 text-danger"> </span>
<color-code value="@Model.ChatHistory[i].Name"></color-code>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</span><br />
}
if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED")
{
<span class="text-light">
<color-code value="@Model.ChatHistory[i].Name"></color-code>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</span>
<span>
&mdash;
<color-code value="@message.CapClientName(48)"></color-code>
<color-code value="@message.CapClientName(48)" allow="@ViewBag.EnableColorCodes"></color-code>
</span><br />
}
}
@ -63,7 +63,7 @@
}
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@Model.Players[i].ClientId" class="@levelColorClass">
<color-code value="@Model.Players[i].Name"></color-code>
<color-code value="@Model.Players[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
@if (ViewBag.Authorized)
@ -88,7 +88,7 @@
<div>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@Model.Players[i].ClientId" class="@levelColorClass">
<color-code value="@Model.Players[i].Name"></color-code>
<color-code value="@Model.Players[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
@if (ViewBag.Authorized)
{
@ -122,26 +122,26 @@
{
<span class="text-light">
<span class="oi oi-account-login mr-2 text-success"> </span>
<color-code value="@Model.ChatHistory[i].Name"></color-code>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</span><br />
}
if (Model.ChatHistory[i].Message == "DISCONNECTED")
{
<span class="text-light">
<span class="oi oi-account-logout mr-2 text-danger"> </span>
<color-code value="@Model.ChatHistory[i].Name"></color-code>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</span><br />
}
if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED")
{
<span class="text-light">
<color-code value="@Model.ChatHistory[i].Name"></color-code>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</span>
<span>
&mdash;
<color-code value="@message.CapClientName(48)"></color-code>
<color-code value="@message.CapClientName(48)" allow="@ViewBag.EnableColorCodes"></color-code>
</span><br />
}
}
}
</div>
</div>

View File

@ -1,56 +0,0 @@
@using WebfrontCore.ViewModels
@using System.Globalization
@model WebfrontCore.ViewModels.ScoreboardInfo
@{
Layout = null;
object OrderByFunc(ClientScoreboardInfo item)
{
var property = typeof(ClientScoreboardInfo).GetProperties().FirstOrDefault(prop =>
prop.CanRead && prop.Name.Equals(Model.OrderByKey, StringComparison.InvariantCultureIgnoreCase));
return property != null ? property.GetValue(item) : item.Score;
}
string GetColumnSortDisplay(string propertyName)
{
if (propertyName == (Model.OrderByKey ?? nameof(ClientScoreboardInfo.Score)))
{
return Model.ShouldOrderDescending ? "<span class=\"ml-2\">▼</span>" : "<span class=\"ml-2\">▲</span>";
}
return null;
}
}
<table class="table table-striped thead-light bg-dark mb-0 table-responsive-md table-sort"
data-sort-column="@(Model.OrderByKey ?? nameof(ClientScoreboardInfo.Score))"
data-sort-down="@Model.ShouldOrderDescending.ToString().ToLower()">
<tr class="bg-dark border-bottom">
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.ClientName)">@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_PLAYER"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.ClientName)))</th>
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.Score)">@ViewBag.Localization["WEBFRONT_ADV_STATS_SCORE"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.Score)))</th>
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.Kills)">@ViewBag.Localization["WEBFRONT_ADV_STATS_KILLS"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.Kills)))</th>
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.Deaths)">@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_DEATHS"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.Deaths)))</th>
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.Kdr)">@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_RATIO"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.Kdr)))</th>
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.ScorePerMinute)">@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_SPM"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.ScorePerMinute)))</th>
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.ZScore)">@ViewBag.Localization["WEBFRONT_ADV_STATS_ZSCORE"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.ZScore)))</th>
<th class="text-right table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.Ping)">@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_PING"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.Ping)))</th>
</tr>
@foreach (var client in Model.ShouldOrderDescending ? Model.ClientInfo.OrderByDescending(OrderByFunc) : Model.ClientInfo.OrderBy(OrderByFunc))
{
<tr>
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@client.ClientId">
<color-code value="@client.ClientName"></color-code>
</a>
</td>
<td>@client.Score</td>
<td>@(client.Kills ?? 0)</td>
<td>@(client.Deaths ?? 0)</td>
<td>@Math.Round(client.Kdr ?? 0, 2)</td>
<td>@Math.Round(client.ScorePerMinute ?? 0)</td>
<td>@(client.ZScore == null ? "--" : Math.Round(client.ZScore.Value, 2).ToString(CultureInfo.CurrentCulture))</td>
<td class="text-right">@client.Ping</td>
</tr>
}
</table>

View File

@ -5,19 +5,15 @@
<div class="row server-header pt-1 pb-1 bg-primary " id="server_header_@Model.ID">
<div class="col-md-4 text-center text-md-left d-inline-flex justify-content-center justify-content-md-start">
<color-code value="@Model.Name"></color-code>
<a href="@Model.ConnectProtocolUrl" class="ml-2 mr-2 align-self-center d-none d-md-flex server-join-button" title="@Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_HOME_JOIN_DESC"]">
<color-code value="@Model.Name" allow="@ViewBag.EnableColorCodes"></color-code>
<a href="@Model.ConnectProtocolUrl" class="ml-2 mr-2 align-self-center d-none d-md-flex server-join-button" title="@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_HOME_JOIN_DESC"]">
<span class="oi oi-play-circle mr-1 align-self-center"></span>
<span class="server-header-ip-address" style="display:none;">@Model.IPAddress</span>
</a>
@if (ViewBag.Authorized)
{
<span class="oi oi-chat align-self-center profile-action d-none d-md-flex mr-2" data-action="chat" data-action-id="@Model.ID"></span>
<span class="oi oi-chat align-self-center profile-action d-none d-md-flex" data-action="chat" data-action-id="@Model.ID"></span>
}
<a asp-controller="Server" asp-action="Scoreboard" asp-fragment="server_@Model.ID" title="@ViewBag.Localization["WEBFRONT_TITLE_SCOREBOARD"]"
class="align-self-center d-none d-md-flex">
<span class="oi oi-spreadsheet ml-1"></span>
</a>
</div>
<div class="text-center col-md-4 align-self-center">
@ -43,14 +39,10 @@
@if (ViewBag.Authorized)
{
<div class="p-1 d-flex d-md-none justify-content-center col-12">
<div class=" p-1 d-flex d-md-none justify-content-center col-12">
<span class="oi oi-chat align-self-center profile-action d-flex d-md-none" data-action="chat" data-action-id="@Model.ID"></span>
</div>
}
<a asp-controller="Server" asp-action="Scoreboard" title="@ViewBag.Localization["WEBFRONT_TITLE_SCOREBOARD"]"
class="p-1 d-flex d-md-none justify-content-center col-12">
<span class="oi oi-spreadsheet ml-1"></span>
</a>
</div>
<div id="server_clientactivity_@Model.ID" class="bg-dark row server-activity @(Model.ClientCount > 0 ? "pt-2 pb-2" : "")">

View File

@ -40,7 +40,7 @@
<div class="p-2 mb-3 border-bottom" style="background-color: #222;">
<div class="d-flex flex-row">
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@client.ClientId" class="h4 mr-auto">
<color-code value="@client.Name"></color-code>
<color-code value="@client.Name" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
<div class="client-location-flag align-self-center" data-ip="@client.IPAddress"></div>
</div>
@ -49,4 +49,4 @@
<div class="align-self-center">@client.LastConnectionText</div>
</div>
</div>
}
}

View File

@ -45,6 +45,7 @@
<None Include="wwwroot\css\global.min.css" CopyToPublishDirectory="PreserveNewest" />
<None Include="wwwroot\js\global.min.js" CopyToPublishDirectory="PreserveNewest" />
<None Include="wwwroot\images\**\*.*" CopyToPublishDirectory="PreserveNewest" />
<Content Remove="wwwroot\images\icons\crosshair.png" />
</ItemGroup>
<ItemGroup>

View File

@ -27,7 +27,6 @@
"wwwroot/js/search.js",
"wwwroot/js/loader.js",
"wwwroot/js/stats.js",
"wwwroot/js/scoreboard.js",
"wwwroot/js/configuration.js",
"wwwroot/js/advanced_stats.js"
],

View File

@ -197,7 +197,7 @@ form *, select, button.btn {
font-size: 1rem;
}
.oi, .table-sort-column {
.oi {
cursor: pointer;
}
@ -454,4 +454,4 @@ div.card {
padding-left: 1rem !important;
padding-right: 1rem !important;
line-height: 1.45rem !important;
}
}

View File

@ -1,32 +0,0 @@
function refreshScoreboard() {
const serverPanel = $('.scoreboard-container.active');
const serverId = $(serverPanel).data('server-id');
const scoreboardTable = $(serverPanel).children('.table-sort');
$.get(`../Server/${serverId}/Scoreboard?order=${scoreboardTable.data('sort-column')}&down=${scoreboardTable.data('sort-down')}`, (response) => {
$(serverPanel).html(response);
setupDataSorting();
});
}
$(document).ready(() => {
$(window.location.hash).tab('show');
$(`${window.location.hash}_nav`).addClass('active');
setupDataSorting();
})
function setupDataSorting() {
const tableColumn = $('.table-sort-column');
$(tableColumn).off('click');
$(tableColumn).on('click', function() {
const columnName = $(this).data('column-name');
const table = $('.table-sort');
$(table).data('sort-column', columnName);
$(table).data('sort-down', $(table).data('sort-down') !== true);
refreshScoreboard();
})
}
setInterval(refreshScoreboard, 5000);