diff --git a/marketplace/Empostor.Plugin.Chat.dll b/marketplace/Empostor.Plugin.Chat.dll index 91e8d9b..fdb019a 100644 Binary files a/marketplace/Empostor.Plugin.Chat.dll and b/marketplace/Empostor.Plugin.Chat.dll differ diff --git a/marketplace/Empostor.Plugin.Code.dll b/marketplace/Empostor.Plugin.Code.dll index 1171dab..91f63e5 100644 Binary files a/marketplace/Empostor.Plugin.Code.dll and b/marketplace/Empostor.Plugin.Code.dll differ diff --git a/marketplace/Empostor.Plugins.ChatFilter.dll b/marketplace/Empostor.Plugins.ChatFilter.dll index 9530f46..8c7f912 100644 Binary files a/marketplace/Empostor.Plugins.ChatFilter.dll and b/marketplace/Empostor.Plugins.ChatFilter.dll differ diff --git a/marketplace/Empostor.Plugins.DiscordWebhook.dll b/marketplace/Empostor.Plugins.DiscordWebhook.dll index 43524e3..3a3e646 100644 Binary files a/marketplace/Empostor.Plugins.DiscordWebhook.dll and b/marketplace/Empostor.Plugins.DiscordWebhook.dll differ diff --git a/marketplace/Empostor.Plugins.Example.dll b/marketplace/Empostor.Plugins.Example.dll index c4f6c54..af01bb5 100644 Binary files a/marketplace/Empostor.Plugins.Example.dll and b/marketplace/Empostor.Plugins.Example.dll differ diff --git a/marketplace/Empostor.Plugins.FixedCode.dll b/marketplace/Empostor.Plugins.FixedCode.dll index de4345d..7befe1e 100644 Binary files a/marketplace/Empostor.Plugins.FixedCode.dll and b/marketplace/Empostor.Plugins.FixedCode.dll differ diff --git a/marketplace/Empostor.Plugins.FriendCodeValidator.dll b/marketplace/Empostor.Plugins.FriendCodeValidator.dll index 1344b6f..ec3bc53 100644 Binary files a/marketplace/Empostor.Plugins.FriendCodeValidator.dll and b/marketplace/Empostor.Plugins.FriendCodeValidator.dll differ diff --git a/marketplace/Empostor.Plugins.Maintenance.dll b/marketplace/Empostor.Plugins.Maintenance.dll index 223303b..cf66ab5 100644 Binary files a/marketplace/Empostor.Plugins.Maintenance.dll and b/marketplace/Empostor.Plugins.Maintenance.dll differ diff --git a/marketplace/Empostor.Plugins.Message.dll b/marketplace/Empostor.Plugins.Message.dll index fe8f5ce..acb5450 100644 Binary files a/marketplace/Empostor.Plugins.Message.dll and b/marketplace/Empostor.Plugins.Message.dll differ diff --git a/marketplace/Empostor.Plugins.Monitor.dll b/marketplace/Empostor.Plugins.Monitor.dll index 5391c86..655ce51 100644 Binary files a/marketplace/Empostor.Plugins.Monitor.dll and b/marketplace/Empostor.Plugins.Monitor.dll differ diff --git a/marketplace/Empostor.Plugins.PlayerChannel.dll b/marketplace/Empostor.Plugins.PlayerChannel.dll index 47a5386..0112391 100644 Binary files a/marketplace/Empostor.Plugins.PlayerChannel.dll and b/marketplace/Empostor.Plugins.PlayerChannel.dll differ diff --git a/marketplace/Empostor.Plugins.PlayerStats.dll b/marketplace/Empostor.Plugins.PlayerStats.dll deleted file mode 100644 index ac7db43..0000000 Binary files a/marketplace/Empostor.Plugins.PlayerStats.dll and /dev/null differ diff --git a/marketplace/Empostor.Plugins.Privacy.dll b/marketplace/Empostor.Plugins.Privacy.dll index 6ba53e0..2eaafeb 100644 Binary files a/marketplace/Empostor.Plugins.Privacy.dll and b/marketplace/Empostor.Plugins.Privacy.dll differ diff --git a/marketplace/Empostor.Plugins.QqVerify.dll b/marketplace/Empostor.Plugins.QqVerify.dll index 8530fbd..20ece2a 100644 Binary files a/marketplace/Empostor.Plugins.QqVerify.dll and b/marketplace/Empostor.Plugins.QqVerify.dll differ diff --git a/marketplace/Empostor.Plugins.Welcome.dll b/marketplace/Empostor.Plugins.Welcome.dll index 51510b6..a0b2e0a 100644 Binary files a/marketplace/Empostor.Plugins.Welcome.dll and b/marketplace/Empostor.Plugins.Welcome.dll differ diff --git a/src/Empostor.Plugins.PlayerStats/Empostor.Plugins.PlayerStats.csproj b/src/Empostor.Plugins.PlayerStats/Empostor.Plugins.PlayerStats.csproj deleted file mode 100644 index 7d6b37b..0000000 --- a/src/Empostor.Plugins.PlayerStats/Empostor.Plugins.PlayerStats.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - net8.0 - Empostor.Plugins.PlayerStats - enable - - - - - - - - diff --git a/src/Empostor.Plugins.PlayerStats/PlayerStatsAdminExtension.cs b/src/Empostor.Plugins.PlayerStats/PlayerStatsAdminExtension.cs deleted file mode 100644 index 10bdf93..0000000 --- a/src/Empostor.Plugins.PlayerStats/PlayerStatsAdminExtension.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Empostor.Api.Admin; - -namespace Empostor.Plugins.PlayerStats; - -public sealed class PlayerStatsAdminExtension : IAdminExtension -{ - private readonly PlayerStatsStore _store; - - public PlayerStatsAdminExtension(PlayerStatsStore store) - { - _store = store; - } - - public string Id => "player-stats"; - - public string Title => "Player Stats"; - - public string Icon => "stats"; - - public void Build(AdminPanelBuilder b) - { - b.RegisterToggle(t => - { - t.Label = "Enable stat recording"; - t.Value = _store.Enabled; - t.OnChange(async ctx => - { - _store.SetEnabled(ctx.Value == "true"); - return AdminActionResult.Ok("Stat recording " + (_store.Enabled ? "enabled." : "disabled.")); - }); - }); - - b.RegisterButton(btn => - { - btn.Label = "Reset all stats"; - btn.Icon = "trash"; - btn.Style = "danger"; - btn.OnClick(async ctx => - { - _store.ClearAll(); - return AdminActionResult.Ok("All statistics reset."); - }); - }); - - b.RegisterTable(table => - { - table.Columns = new List - { - "Friend Code", "Name", "Games", "Wins", "Losses", "Imp. Wins", "Kills", "Deaths", "Tasks", "Exiled", - }; - table.Rows = _store.GetAll().Select(s => new List - { - new() { Text = s.FriendCode, Monospace = true }, - new() { Text = s.LastKnownName ?? "—" }, - new() { Text = s.GamesPlayed.ToString() }, - new() { Text = s.Wins.ToString() }, - new() { Text = s.Losses.ToString() }, - new() { Text = s.ImpostorWins.ToString() }, - new() { Text = s.Kills.ToString() }, - new() { Text = s.Deaths.ToString() }, - new() { Text = s.TasksCompleted.ToString() }, - new() { Text = s.TimesExiled.ToString() }, - }).ToList(); - }); - } -} diff --git a/src/Empostor.Plugins.PlayerStats/PlayerStatsConfig.cs b/src/Empostor.Plugins.PlayerStats/PlayerStatsConfig.cs deleted file mode 100644 index 9713984..0000000 --- a/src/Empostor.Plugins.PlayerStats/PlayerStatsConfig.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Empostor.Plugins.PlayerStats; - -public sealed class PlayerStatsConfig -{ - public bool Enabled { get; set; } - - public bool PersistToFile { get; set; } = true; -} diff --git a/src/Empostor.Plugins.PlayerStats/PlayerStatsEntry.cs b/src/Empostor.Plugins.PlayerStats/PlayerStatsEntry.cs deleted file mode 100644 index 49f1356..0000000 --- a/src/Empostor.Plugins.PlayerStats/PlayerStatsEntry.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; - -namespace Empostor.Plugins.PlayerStats; - -public sealed class PlayerStatsEntry -{ - public string FriendCode { get; init; } = string.Empty; - - public string? LastKnownName { get; set; } - - public int GamesPlayed { get; set; } - - public int Wins { get; set; } - - public int Losses { get; set; } - - public int ImpostorWins { get; set; } - - public int Kills { get; set; } - - public int Deaths { get; set; } - - public int TasksCompleted { get; set; } - - public int TimesExiled { get; set; } - - public DateTime FirstSeen { get; init; } = DateTime.UtcNow; - - public DateTime LastSeen { get; set; } = DateTime.UtcNow; -} diff --git a/src/Empostor.Plugins.PlayerStats/PlayerStatsListener.cs b/src/Empostor.Plugins.PlayerStats/PlayerStatsListener.cs deleted file mode 100644 index a9199a4..0000000 --- a/src/Empostor.Plugins.PlayerStats/PlayerStatsListener.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System.Linq; -using Empostor.Api.Events; -using Empostor.Api.Events.Player; -using Empostor.Api.Games; -using Empostor.Api.Net.Inner.Objects; - -namespace Empostor.Plugins.PlayerStats; - -public sealed class PlayerStatsListener : IEventListener -{ - private readonly PlayerStatsStore _store; - - public PlayerStatsListener(PlayerStatsStore store) - { - _store = store; - } - - [EventListener] - public void OnPlayerMurder(IPlayerMurderEvent e) - { - if (!_store.Enabled) - { - return; - } - - var killerFc = e.ClientPlayer.Client.FriendCode; - if (killerFc != null) - { - _store.RecordKill(killerFc); - _store.GetOrCreate(killerFc, e.ClientPlayer.Client.Name); - } - - var victimFc = GetFriendCode(e.Game, e.Victim); - if (victimFc != null) - { - _store.RecordDeath(victimFc); - } - } - - [EventListener] - public void OnPlayerCompletedTask(IPlayerCompletedTaskEvent e) - { - if (!_store.Enabled) - { - return; - } - - var fc = e.ClientPlayer.Client.FriendCode; - if (fc != null) - { - _store.RecordTaskCompleted(fc); - _store.GetOrCreate(fc, e.ClientPlayer.Client.Name); - } - } - - [EventListener] - public void OnPlayerExile(IPlayerExileEvent e) - { - if (!_store.Enabled) - { - return; - } - - var fc = e.ClientPlayer.Client.FriendCode; - if (fc != null) - { - _store.RecordExile(fc); - _store.GetOrCreate(fc, e.ClientPlayer.Client.Name); - } - } - - [EventListener] - public void OnGameEnded(IGameEndedEvent e) - { - if (!_store.Enabled) - { - return; - } - - var reason = e.GameOverReason.ToString(); - var isCrewmateWin = reason.StartsWith("Crewmates") || reason == "HideAndSeek_CrewmatesByTimer"; - - foreach (var player in e.Game.Players) - { - var fc = player.Client.FriendCode; - if (fc == null) - { - continue; - } - - var wasImpostor = player.Character?.PlayerInfo?.IsImpostor ?? false; - _store.RecordGameEnd(fc, player.Client.Name, isCrewmateWin, wasImpostor); - } - } - - private static string? GetFriendCode(IGame game, IInnerPlayerControl target) - { - var match = game.Players.FirstOrDefault(p => p.Character?.PlayerId == target.PlayerId); - return match?.Client.FriendCode; - } -} diff --git a/src/Empostor.Plugins.PlayerStats/PlayerStatsPlugin.cs b/src/Empostor.Plugins.PlayerStats/PlayerStatsPlugin.cs deleted file mode 100644 index 4b236ce..0000000 --- a/src/Empostor.Plugins.PlayerStats/PlayerStatsPlugin.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Threading.Tasks; -using Empostor.Api.Plugins; -using Microsoft.Extensions.Logging; - -namespace Empostor.Plugins.PlayerStats; - -[EmpostorPlugin("cn.hayashiume.playerstats", "Player Stats", "HayashiUme", "2.0.0")] -public sealed class PlayerStatsPlugin : PluginBase -{ - private readonly ILogger _logger; - - public PlayerStatsPlugin(ILogger logger) - { - _logger = logger; - } - - public override ValueTask EnableAsync() - { - _logger.LogInformation("[PlayerStats] Enabled. View and reset statistics in the admin panel (Plugins → Player Stats)."); - return default; - } - - public override ValueTask DisableAsync() => default; -} diff --git a/src/Empostor.Plugins.PlayerStats/PlayerStatsPluginStartup.cs b/src/Empostor.Plugins.PlayerStats/PlayerStatsPluginStartup.cs deleted file mode 100644 index f51f1c5..0000000 --- a/src/Empostor.Plugins.PlayerStats/PlayerStatsPluginStartup.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Empostor.Api.Admin; -using Empostor.Api.Commands; -using Empostor.Api.Events; -using Empostor.Api.Plugins; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; - -namespace Empostor.Plugins.PlayerStats; - -public sealed class PlayerStatsPluginStartup : IPluginStartup -{ - public void ConfigureHost(IHostBuilder host) { } - - public void ConfigureServices(IServiceCollection services) - { - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - } -} diff --git a/src/Empostor.Plugins.PlayerStats/PlayerStatsStore.cs b/src/Empostor.Plugins.PlayerStats/PlayerStatsStore.cs deleted file mode 100644 index ad844fb..0000000 --- a/src/Empostor.Plugins.PlayerStats/PlayerStatsStore.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Empostor.Api.Plugins; -using Empostor.Api.Service; -using Microsoft.Extensions.Logging; - -namespace Empostor.Plugins.PlayerStats; - -public sealed class PlayerStatsStore : JsonDataStore> -{ - private const string ConfigFile = "[Empostor.Plugins.PlayerStats]Config.json"; - - private ConcurrentDictionary _stats = new(StringComparer.OrdinalIgnoreCase); - - public PlayerStatsStore(ILogger logger) - : base(logger, legacyPath: "Data/player_stats.json") - { - Load(); - var cfg = PluginConfigLoader.Load(ConfigPath()); - Enabled = cfg.Enabled; - } - - public bool Enabled { get; private set; } - - public void SetEnabled(bool value) - { - Enabled = value; - var path = ConfigPath(); - var cfg = PluginConfigLoader.Load(path); - cfg.Enabled = value; - PluginConfigLoader.Save(path, cfg); - } - - public PlayerStatsEntry GetOrCreate(string friendCode, string? name = null) - { - var fc = Normalize(friendCode); - var entry = _stats.GetOrAdd(fc, _ => new PlayerStatsEntry { FriendCode = fc, FirstSeen = DateTime.UtcNow }); - if (name != null) - { - entry.LastKnownName = name; - } - - entry.LastSeen = DateTime.UtcNow; - return entry; - } - - public PlayerStatsEntry? GetByFriendCode(string friendCode) - => _stats.TryGetValue(Normalize(friendCode), out var e) ? e : null; - - public void RecordKill(string friendCode) - { - var e = GetOrCreate(friendCode); - e.Kills++; - SaveFireAndForget(); - } - - public void RecordDeath(string friendCode) - { - var e = GetOrCreate(friendCode); - e.Deaths++; - SaveFireAndForget(); - } - - public void RecordTaskCompleted(string friendCode) - { - var e = GetOrCreate(friendCode); - e.TasksCompleted++; - SaveFireAndForget(); - } - - public void RecordExile(string friendCode) - { - var e = GetOrCreate(friendCode); - e.TimesExiled++; - SaveFireAndForget(); - } - - public void RecordGameEnd(string friendCode, string? name, bool isCrewmateWin, bool wasImpostor) - { - var e = GetOrCreate(friendCode, name); - e.GamesPlayed++; - if (wasImpostor) - { - if (!isCrewmateWin) - { - e.ImpostorWins++; - } - } - else - { - if (isCrewmateWin) - { - e.Wins++; - } - else - { - e.Losses++; - } - } - - SaveFireAndForget(); - } - - public List GetAll() - => _stats.Values.OrderByDescending(s => s.GamesPlayed).ToList(); - - public void ClearAll() - { - _stats.Clear(); - SaveFireAndForget(); - } - - protected override List GetSnapshot() => _stats.Values.ToList(); - - protected override void ApplySnapshot(List data) - { - _stats = new ConcurrentDictionary( - data.ToDictionary(e => e.FriendCode, StringComparer.OrdinalIgnoreCase)); - } - - private static string Normalize(string friendCode) - => (friendCode ?? string.Empty).Trim(); - - private static string ConfigPath() => Path.Combine(Directory.GetCurrentDirectory(), ConfigFile); -} diff --git a/src/Empostor.Plugins.PlayerStats/StatCommand.cs b/src/Empostor.Plugins.PlayerStats/StatCommand.cs deleted file mode 100644 index 92a9004..0000000 --- a/src/Empostor.Plugins.PlayerStats/StatCommand.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Threading.Tasks; -using Empostor.Api.Commands; - -namespace Empostor.Plugins.PlayerStats; - -public sealed class StatCommand : ICommand -{ - private readonly PlayerStatsStore _store; - - public StatCommand(PlayerStatsStore store) - { - _store = store; - } - - public string Name => "stat"; - - public string[] Aliases => new[] { "stats", "mystats" }; - - public string Description => "Show your game statistics."; - - public string Usage => "stat"; - - public async ValueTask ExecuteAsync(CommandContext ctx) - { - if (!_store.Enabled) - { - await ctx.PlayerControl.SendChatToPlayerAsync( - ctx.GetString("command.stat.disabled"), ctx.PlayerControl); - return true; - } - - var fc = ctx.Sender.Client.FriendCode; - if (string.IsNullOrEmpty(fc)) - { - await ctx.PlayerControl.SendChatToPlayerAsync( - ctx.GetString("command.stat.no_stats"), ctx.PlayerControl); - return true; - } - - var stats = _store.GetByFriendCode(fc); - if (stats == null) - { - await ctx.PlayerControl.SendChatToPlayerAsync( - ctx.GetString("command.stat.no_stats"), ctx.PlayerControl); - return true; - } - - async Task Send(string key, params object[] args) - => await ctx.PlayerControl.SendChatToPlayerAsync( - ctx.GetString(key, args), ctx.PlayerControl); - - await Send("command.stat.header"); - await Send("command.stat.games", stats.GamesPlayed); - await Send("command.stat.wins", stats.Wins); - await Send("command.stat.losses", stats.Losses); - await Send("command.stat.impostor", stats.ImpostorWins); - await Send("command.stat.kills", stats.Kills); - await Send("command.stat.deaths", stats.Deaths); - await Send("command.stat.tasks", stats.TasksCompleted); - await Send("command.stat.exiled", stats.TimesExiled); - - return true; - } -} diff --git a/src/Empostor.Plugins.PlayerStats/packages.lock.json b/src/Empostor.Plugins.Titles/packages.lock.json similarity index 100% rename from src/Empostor.Plugins.PlayerStats/packages.lock.json rename to src/Empostor.Plugins.Titles/packages.lock.json diff --git a/src/Empostor.sln b/src/Empostor.sln index 9186f62..b424139 100644 --- a/src/Empostor.sln +++ b/src/Empostor.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 18 -VisualStudioVersion = 18.5.11709.299 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Empostor.Server", "Empostor.Server\Empostor.Server.csproj", "{1B0390AF-A4F3-4FE4-B093-708B0135C0B3}" EndProject