From 2252aaab470e2ca58a21948f9edd2b68a6d0dbcb Mon Sep 17 00:00:00 2001 From: K4ryuu <104531589+K4ryuu@users.noreply.github.com> Date: Tue, 8 Oct 2024 21:25:39 +0200 Subject: [PATCH] Release v2.3.4 --- CHANGELOG | 5 +++++ src/K4ryuuDamageInfo.cs | 34 +++++++++++++++++----------------- src/lang/cn.json | 38 +++++++++++++++++++------------------- src/lang/en.json | 36 ++++++++++++++++++------------------ src/lang/pl.json | 36 ++++++++++++++++++------------------ 5 files changed, 77 insertions(+), 72 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3a0d466..8bbf7d8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +-- 2024.10.08 - V2.3.4 + +- uprade: Optimised and simplified some parts a little bit +- fix: Errors after CS2 update + -- 2024.07.24 - V2.3.3 - upgrade: update to NET8.0 from NET7.0 diff --git a/src/K4ryuuDamageInfo.cs b/src/K4ryuuDamageInfo.cs index 7790b0f..a8c6157 100644 --- a/src/K4ryuuDamageInfo.cs +++ b/src/K4ryuuDamageInfo.cs @@ -46,7 +46,7 @@ public sealed class PluginConfig : BasePluginConfig "@myplugin/can-see-permission", "#myplugin/can-see-group", "can-see-override", - "leave-empty-so-let-everyone-see" + "leave-empty-so-everyone-see-it" }; [JsonPropertyName("ConfigVersion")] @@ -57,13 +57,13 @@ public sealed class PluginConfig : BasePluginConfig public class DamageInfoPlugin : BasePlugin, IPluginConfig { public override string ModuleName => "Damage Informations"; - public override string ModuleVersion => "2.3.3"; + public override string ModuleVersion => "2.3.4"; public override string ModuleAuthor => "K4ryuu @ KitsuneLab"; public required PluginConfig Config { get; set; } = new PluginConfig(); public CCSGameRules? GameRules; - private bool[] IsDataShown = new bool[65]; - private int[] VictimKiller = new int[65]; + private readonly bool[] IsDataShown = new bool[65]; + private readonly int[] VictimKiller = new int[65]; public void OnConfigParsed(PluginConfig config) { @@ -123,11 +123,11 @@ private HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) if (Config.NoRoundsMode) { - if (!playerDamageInfos.ContainsKey(victim.Slot) || playerDamageInfos[victim.Slot] is null) + if (!playerDamageInfos.TryGetValue(victim.Slot, out PlayerDamageInfo? value) || value is null) return HookResult.Continue; - playerDamageInfos[victim.Slot].GivenDamage.Clear(); - playerDamageInfos[victim.Slot].TakenDamage.Clear(); + value.GivenDamage.Clear(); + value.TakenDamage.Clear(); } return HookResult.Continue; @@ -166,7 +166,7 @@ private HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info) if (!recentDamages.ContainsKey(attacker.Slot)) { - recentDamages[attacker.Slot] = new Dictionary(); + recentDamages[attacker.Slot] = []; } if (!recentDamages[attacker.Slot].TryGetValue(victim.Slot, out RecentDamage? recentDamage)) @@ -254,7 +254,7 @@ private void DisplayDamageInfo(CCSPlayerController player) if (Config.ShowAllDamages) { - Dictionary? allPlayerSummaries = new Dictionary(); + Dictionary? allPlayerSummaries = []; IsDataShown[player.Slot] = true; @@ -297,15 +297,15 @@ private void DisplayDamageInfo(CCSPlayerController player) } else { - if (!playerDamageInfos.ContainsKey(player.Slot) || playerDamageInfos[player.Slot] is null) + if (!playerDamageInfos.TryGetValue(player.Slot, out PlayerDamageInfo? value) || value is null) return; IsDataShown[player.Slot] = true; - DisplayPlayerDamageInfo(player, playerDamageInfos[player.Slot]); + DisplayPlayerDamageInfo(player, value); } } - private (DamageInfo given, DamageInfo taken) SummarizePlayerDamage(PlayerDamageInfo playerInfo) + private static (DamageInfo given, DamageInfo taken) SummarizePlayerDamage(PlayerDamageInfo playerInfo) { DamageInfo totalGivenDamage = new DamageInfo(); DamageInfo totalTakenDamage = new DamageInfo(); @@ -343,7 +343,7 @@ private void DisplayPlayerDamageInfo(CCSPlayerController player, PlayerDamageInf printed = true; DamageInfo givenDamageInfo = entry.Value; - DamageInfo takenDamageInfo = playerInfo.TakenDamage.ContainsKey(otherPlayerId) ? playerInfo.TakenDamage[otherPlayerId] : new DamageInfo(); + DamageInfo takenDamageInfo = playerInfo.TakenDamage.TryGetValue(otherPlayerId, out DamageInfo? value) ? value : new DamageInfo(); processedPlayers.Add(otherPlayerId); int otherPlayerHealth = 0; @@ -394,12 +394,12 @@ private void DisplayPlayerDamageInfo(CCSPlayerController player, PlayerDamageInf player.PrintToChat($" {Localizer["phrases.summary.endline"]}"); } - private Dictionary playerDamageInfos = new Dictionary(); + private readonly Dictionary playerDamageInfos = new Dictionary(); private class PlayerDamageInfo { - public Dictionary GivenDamage = new Dictionary(); - public Dictionary TakenDamage = new Dictionary(); + public Dictionary GivenDamage = []; + public Dictionary TakenDamage = []; } private class DamageInfo @@ -408,7 +408,7 @@ private class DamageInfo public int Hits = 0; } - private Dictionary> recentDamages = new Dictionary>(); + private readonly Dictionary> recentDamages = []; private class RecentDamage { diff --git a/src/lang/cn.json b/src/lang/cn.json index bed95b8..18038ef 100644 --- a/src/lang/cn.json +++ b/src/lang/cn.json @@ -1,20 +1,20 @@ { - "phrases.summary.startline": "▬▬▬▬▬▬▬▬▬▬▬▬▬ 统计信息 ▬▬▬▬▬▬▬▬▬▬▬▬▬", - "phrases.summary.dataline": "{lime}➜ {white}给: [{lime}{0} / {1} 次命中{white}] 承受: [{lightred}{2} / {3} 次命中{white}] - {4} [{lightred}{5}{white}]", - "phrases.summary.endline": "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬", - "phrases.center.deadly": "造成伤害:\nHP {0} | 受伤部位: {1}", - "phrases.center.normal": "造成伤害:\nHP {0} | 护甲 {1} | 受伤部位: {2}", - "phrases.console.normal": "对 {0} 造成伤害 | HP {1} | 护甲 {2} | 受伤部位: {3}", - "phrases.console.inverse": "从 {0} 受到伤害 | HP {1} | 护甲 {2} | 受伤部位: {3}", - "phrases.dead": "死亡", - "phrases.hitgroup.0": "身体", - "phrases.hitgroup.1": "头部", - "phrases.hitgroup.2": "胸部", - "phrases.hitgroup.3": "腹部", - "phrases.hitgroup.4": "左臂", - "phrases.hitgroup.5": "右臂", - "phrases.hitgroup.6": "左腿", - "phrases.hitgroup.7": "右腿", - "phrases.hitgroup.10": "装备", - "phrases.hitgroup._": "未知" -} \ No newline at end of file + "phrases.summary.startline": "▬▬▬▬▬▬▬▬▬▬▬▬▬ 统计信息 ▬▬▬▬▬▬▬▬▬▬▬▬▬", + "phrases.summary.dataline": "{lime}➜ {white}给: [{lime}{0} / {1} 次命中{white}] 承受: [{lightred}{2} / {3} 次命中{white}] - {4} [{lightred}{5}{white}]", + "phrases.summary.endline": "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬", + "phrases.center.deadly": "造成伤害:\nHP {0} | 受伤部位: {1}", + "phrases.center.normal": "造成伤害:\nHP {0} | 护甲 {1} | 受伤部位: {2}", + "phrases.console.normal": "对 {0} 造成伤害 | HP {1} | 护甲 {2} | 受伤部位: {3}", + "phrases.console.inverse": "从 {0} 受到伤害 | HP {1} | 护甲 {2} | 受伤部位: {3}", + "phrases.dead": "死亡", + "phrases.hitgroup.0": "身体", + "phrases.hitgroup.1": "头部", + "phrases.hitgroup.2": "胸部", + "phrases.hitgroup.3": "腹部", + "phrases.hitgroup.4": "左臂", + "phrases.hitgroup.5": "右臂", + "phrases.hitgroup.6": "左腿", + "phrases.hitgroup.7": "右腿", + "phrases.hitgroup.10": "装备", + "phrases.hitgroup._": "未知" +} diff --git a/src/lang/en.json b/src/lang/en.json index 4613664..3279558 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1,20 +1,20 @@ { - "phrases.summary.startline": "▬▬▬▬▬▬▬▬▬▬▬▬▬ Statistics ▬▬▬▬▬▬▬▬▬▬▬▬▬", - "phrases.summary.dataline": "{lime}➜ {white}To: [{lime}{0} / {1} hits{white}] From: [{lightred}{2} / {3} hits{white}] - {4} [{lightred}{5}{white}]", - "phrases.summary.endline": "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬", - "phrases.center.deadly": "Damage Given:\nHP {0} | HitGroup: {1}", - "phrases.center.normal": "Damage Given:\nHP {0} | Armor {1} | HitGroup: {2}", - "phrases.console.normal": "Damage Given To: {0} | HP {1} | Armor {2} | HitGroup: {3}", - "phrases.console.inverse": "Damage Taken From: {0} | HP {1} | Armor {2} | HitGroup: {3}", - "phrases.dead": "DEAD", - "phrases.hitgroup.0": "Body", - "phrases.hitgroup.1": "Head", - "phrases.hitgroup.2": "Chest", - "phrases.hitgroup.3": "Stomach", - "phrases.hitgroup.4": "Left Arm", - "phrases.hitgroup.5": "Right Arm", - "phrases.hitgroup.6": "Left Leg", - "phrases.hitgroup.7": "Right Leg", - "phrases.hitgroup.10": "Gear", - "phrases.hitgroup._": "Unknown" + "phrases.summary.startline": "▬▬▬▬▬▬▬▬▬▬▬▬▬ Statistics ▬▬▬▬▬▬▬▬▬▬▬▬▬", + "phrases.summary.dataline": "{lime}➜ {white}To: [{lime}{0} / {1} hits{white}] From: [{lightred}{2} / {3} hits{white}] - {4} [{lightred}{5}{white}]", + "phrases.summary.endline": "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬", + "phrases.center.deadly": "Damage Given:\nHP {0} | HitGroup: {1}", + "phrases.center.normal": "Damage Given:\nHP {0} | Armor {1} | HitGroup: {2}", + "phrases.console.normal": "Damage Given To: {0} | HP {1} | Armor {2} | HitGroup: {3}", + "phrases.console.inverse": "Damage Taken From: {0} | HP {1} | Armor {2} | HitGroup: {3}", + "phrases.dead": "DEAD", + "phrases.hitgroup.0": "Body", + "phrases.hitgroup.1": "Head", + "phrases.hitgroup.2": "Chest", + "phrases.hitgroup.3": "Stomach", + "phrases.hitgroup.4": "Left Arm", + "phrases.hitgroup.5": "Right Arm", + "phrases.hitgroup.6": "Left Leg", + "phrases.hitgroup.7": "Right Leg", + "phrases.hitgroup.10": "Gear", + "phrases.hitgroup._": "Unknown" } diff --git a/src/lang/pl.json b/src/lang/pl.json index e84577f..29291ca 100644 --- a/src/lang/pl.json +++ b/src/lang/pl.json @@ -1,20 +1,20 @@ { - "phrases.summary.startline": "▬▬▬▬▬▬▬▬▬▬▬▬▬ Statystyki ▬▬▬▬▬▬▬▬▬▬▬▬▬", - "phrases.summary.dataline": "{lime}➜ {white}Zadane: [{lime}{0} / {1} hits{white}] Otrzymane: [{lightred}{2} / {3} hits{white}] - {4} [{lightred}{5}{white}]", - "phrases.summary.endline": "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬", - "phrases.center.deadly": "Otrzymane obrażenia:\nHP {0} | HitGroup: {1}", - "phrases.center.normal": "Zadane obrażenia:\nHP {0} | Kamizelka {1} | HitGroup: {2}", - "phrases.console.normal": "Zadane obrażenia: {0} | HP {1} | Kamizelka {2} | HitGroup: {3}", - "phrases.console.inverse": "Obrażenia poniesione przez: {0} | HP {1} | Kamizelka {2} | HitGroup: {3}", - "phrases.dead": "Nie żyje", - "phrases.hitgroup.0": "Ciało", - "phrases.hitgroup.1": "Głowa", - "phrases.hitgroup.2": "Klatka piersiowa", - "phrases.hitgroup.3": "Brzuch", - "phrases.hitgroup.4": "Lewe ramię", - "phrases.hitgroup.5": "Prawe ramię", - "phrases.hitgroup.6": "Lewa noga", - "phrases.hitgroup.7": "Prawa noga", - "phrases.hitgroup.10": "W biegu", - "phrases.hitgroup._": "Nieznane" + "phrases.summary.startline": "▬▬▬▬▬▬▬▬▬▬▬▬▬ Statystyki ▬▬▬▬▬▬▬▬▬▬▬▬▬", + "phrases.summary.dataline": "{lime}➜ {white}Zadane: [{lime}{0} / {1} hits{white}] Otrzymane: [{lightred}{2} / {3} hits{white}] - {4} [{lightred}{5}{white}]", + "phrases.summary.endline": "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬", + "phrases.center.deadly": "Otrzymane obrażenia:\nHP {0} | HitGroup: {1}", + "phrases.center.normal": "Zadane obrażenia:\nHP {0} | Kamizelka {1} | HitGroup: {2}", + "phrases.console.normal": "Zadane obrażenia: {0} | HP {1} | Kamizelka {2} | HitGroup: {3}", + "phrases.console.inverse": "Obrażenia poniesione przez: {0} | HP {1} | Kamizelka {2} | HitGroup: {3}", + "phrases.dead": "Nie żyje", + "phrases.hitgroup.0": "Ciało", + "phrases.hitgroup.1": "Głowa", + "phrases.hitgroup.2": "Klatka piersiowa", + "phrases.hitgroup.3": "Brzuch", + "phrases.hitgroup.4": "Lewe ramię", + "phrases.hitgroup.5": "Prawe ramię", + "phrases.hitgroup.6": "Lewa noga", + "phrases.hitgroup.7": "Prawa noga", + "phrases.hitgroup.10": "W biegu", + "phrases.hitgroup._": "Nieznane" }