mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 23:31:13 -05:00
abstract engine color codes to use (Color::<Color>) format to make codes more.
see pt6 parser and configs for example usages
This commit is contained in:
@ -9,8 +9,8 @@ using Data.Models.Client.Stats;
|
||||
using SharedLibraryCore.Database.Models;
|
||||
using SharedLibraryCore.Configuration;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using IW4MAdmin.Plugins.Stats.Config;
|
||||
using IW4MAdmin.Plugins.Stats.Helpers;
|
||||
using Stats.Config;
|
||||
|
||||
namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
{
|
||||
@ -76,7 +76,7 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
|
||||
var iqList = await iqStats.ToListAsync();
|
||||
|
||||
return iqList.Select((stats, index) => translationLookup["PLUGINS_STATS_COMMANDS_MOSTKILLS_FORMAT"]
|
||||
return iqList.Select((stats, index) => translationLookup["PLUGINS_STATS_COMMANDS_MOSTKILLS_FORMAT_V2"]
|
||||
.FormatExt(index + 1, stats.Name, stats.Kills))
|
||||
.Prepend(Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_STATS_COMMANDS_MOSTKILLS_HEADER"]);
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
{
|
||||
var serverId = StatManager.GetIdForServer(s);
|
||||
|
||||
var mostPlayed = new List<string>()
|
||||
var mostPlayed = new List<string>
|
||||
{
|
||||
$"^5--{translationLookup["PLUGINS_STATS_COMMANDS_MOSTPLAYED_TEXT"]}--"
|
||||
$"(Color::Accent)--{translationLookup["PLUGINS_STATS_COMMANDS_MOSTPLAYED_TEXT"]}--"
|
||||
};
|
||||
|
||||
await using var context = contextFactory.CreateContext(false);
|
||||
@ -48,7 +48,7 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
var iqList = await iqStats.ToListAsync();
|
||||
|
||||
mostPlayed.AddRange(iqList.Select((stats, index) =>
|
||||
$"#{index + 1} " + translationLookup["COMMANDS_MOST_PLAYED_FORMAT"].FormatExt(stats.Name, stats.Kills,
|
||||
$"#{index + 1} " + translationLookup["COMMANDS_MOST_PLAYED_FORMAT_V2"].FormatExt(stats.Name, stats.Kills,
|
||||
(DateTime.UtcNow - DateTime.UtcNow.AddSeconds(-stats.TimePlayed))
|
||||
.HumanizeForCurrentCulture())));
|
||||
|
||||
|
@ -1,35 +1,32 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using SharedLibraryCore;
|
||||
using System.Collections.Generic;
|
||||
using Data.Abstractions;
|
||||
using Data.Models.Client.Stats;
|
||||
using SharedLibraryCore.Database.Models;
|
||||
using IW4MAdmin.Plugins.Stats.Helpers;
|
||||
using SharedLibraryCore.Configuration;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using EFClient = Data.Models.Client.EFClient;
|
||||
|
||||
namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
{
|
||||
class TopStats : Command
|
||||
public class TopStats : Command
|
||||
{
|
||||
public static async Task<List<string>> GetTopStats(Server s, ITranslationLookup translationLookup)
|
||||
{
|
||||
long serverId = StatManager.GetIdForServer(s);
|
||||
var serverId = StatManager.GetIdForServer(s);
|
||||
var topStatsText = new List<string>()
|
||||
{
|
||||
$"^5--{translationLookup["PLUGINS_STATS_COMMANDS_TOP_TEXT"]}--"
|
||||
$"(Color::Accent)--{translationLookup["PLUGINS_STATS_COMMANDS_TOP_TEXT"]}--"
|
||||
};
|
||||
|
||||
var stats = await Plugin.Manager.GetTopStats(0, 5, serverId);
|
||||
var statsList = stats.Select((stats, index) => $"#{index + 1} ^3{stats.Name}^7 - ^5{stats.KDR} ^7{translationLookup["PLUGINS_STATS_TEXT_KDR"]} | ^5{stats.Performance} ^7{translationLookup["PLUGINS_STATS_COMMANDS_PERFORMANCE"]}");
|
||||
var statsList = stats.Select((stats, index) =>
|
||||
translationLookup["COMMANDS_TOPSTATS_RESULT"]
|
||||
.FormatExt(index + 1, stats.Name, stats.KDR, stats.Performance));
|
||||
|
||||
topStatsText.AddRange(statsList);
|
||||
|
||||
// no one qualified
|
||||
// no one qualified
|
||||
if (topStatsText.Count == 1)
|
||||
{
|
||||
topStatsText = new List<string>()
|
||||
@ -41,11 +38,10 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
return topStatsText;
|
||||
}
|
||||
|
||||
private readonly CommandConfiguration _config;
|
||||
private readonly IDatabaseContextFactory _contextFactory;
|
||||
private new readonly CommandConfiguration _config;
|
||||
|
||||
public TopStats(CommandConfiguration config, ITranslationLookup translationLookup,
|
||||
IDatabaseContextFactory contextFactory) : base(config, translationLookup)
|
||||
public TopStats(CommandConfiguration config, ITranslationLookup translationLookup) : base(config,
|
||||
translationLookup)
|
||||
{
|
||||
Name = "topstats";
|
||||
Description = translationLookup["PLUGINS_STATS_COMMANDS_TOP_DESC"];
|
||||
@ -54,7 +50,6 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
RequiresTarget = false;
|
||||
|
||||
_config = config;
|
||||
_contextFactory = contextFactory;
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(GameEvent E)
|
||||
@ -76,4 +71,4 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -24,9 +24,9 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
Alias = "xlrstats";
|
||||
Permission = EFClient.Permission.User;
|
||||
RequiresTarget = false;
|
||||
Arguments = new CommandArgument[]
|
||||
Arguments = new []
|
||||
{
|
||||
new CommandArgument()
|
||||
new CommandArgument
|
||||
{
|
||||
Name = "player",
|
||||
Required = false
|
||||
@ -73,14 +73,15 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
if (pStats == null)
|
||||
{
|
||||
await using var context = _contextFactory.CreateContext(false);
|
||||
pStats = (await context.Set<EFClientStatistics>()
|
||||
.FirstOrDefaultAsync(c => c.ServerId == serverId && c.ClientId == E.Target.ClientId));
|
||||
pStats = await context.Set<EFClientStatistics>()
|
||||
.FirstOrDefaultAsync(c => c.ServerId == serverId && c.ClientId == E.Target.ClientId);
|
||||
}
|
||||
|
||||
// if it's still null then they've not gotten a kill or death yet
|
||||
statLine = pStats == null
|
||||
? _translationLookup["PLUGINS_STATS_COMMANDS_NOTAVAILABLE"]
|
||||
: $"^5{pStats.Kills} ^7{_translationLookup["PLUGINS_STATS_TEXT_KILLS"]} | ^5{pStats.Deaths} ^7{_translationLookup["PLUGINS_STATS_TEXT_DEATHS"]} | ^5{pStats.KDR} ^7KDR | ^5{pStats.Performance} ^7{_translationLookup["PLUGINS_STATS_COMMANDS_PERFORMANCE"].ToUpper()} | {performanceRankingString}";
|
||||
: _translationLookup["COMMANDS_VIEW_STATS_RESULT"].FormatExt(pStats.Kills, pStats.Deaths,
|
||||
pStats.KDR, pStats.Performance, performanceRankingString);
|
||||
}
|
||||
|
||||
// getting self stats
|
||||
@ -108,7 +109,8 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
// if it's still null then they've not gotten a kill or death yet
|
||||
statLine = pStats == null
|
||||
? _translationLookup["PLUGINS_STATS_COMMANDS_NOTAVAILABLE"]
|
||||
: $"^5{pStats.Kills} ^7{_translationLookup["PLUGINS_STATS_TEXT_KILLS"]} | ^5{pStats.Deaths} ^7{_translationLookup["PLUGINS_STATS_TEXT_DEATHS"]} | ^5{pStats.KDR} ^7KDR | ^5{pStats.Performance} ^7{_translationLookup["PLUGINS_STATS_COMMANDS_PERFORMANCE"].ToUpper()} | {performanceRankingString}";
|
||||
: _translationLookup["COMMANDS_VIEW_STATS_RESULT"].FormatExt(pStats.Kills, pStats.Deaths,
|
||||
pStats.KDR, pStats.Performance, performanceRankingString);
|
||||
}
|
||||
|
||||
if (E.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix))
|
||||
|
Reference in New Issue
Block a user