Skip to content

Commit

Permalink
Release v2.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
K4ryuu committed Oct 8, 2024
1 parent fe4245b commit 2252aaa
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 72 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
34 changes: 17 additions & 17 deletions src/K4ryuuDamageInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -57,13 +57,13 @@ public sealed class PluginConfig : BasePluginConfig
public class DamageInfoPlugin : BasePlugin, IPluginConfig<PluginConfig>
{
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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -166,7 +166,7 @@ private HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info)

if (!recentDamages.ContainsKey(attacker.Slot))
{
recentDamages[attacker.Slot] = new Dictionary<int, RecentDamage>();
recentDamages[attacker.Slot] = [];
}

if (!recentDamages[attacker.Slot].TryGetValue(victim.Slot, out RecentDamage? recentDamage))
Expand Down Expand Up @@ -254,7 +254,7 @@ private void DisplayDamageInfo(CCSPlayerController player)

if (Config.ShowAllDamages)
{
Dictionary<int, (DamageInfo given, DamageInfo taken)>? allPlayerSummaries = new Dictionary<int, (DamageInfo given, DamageInfo taken)>();
Dictionary<int, (DamageInfo given, DamageInfo taken)>? allPlayerSummaries = [];

IsDataShown[player.Slot] = true;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -394,12 +394,12 @@ private void DisplayPlayerDamageInfo(CCSPlayerController player, PlayerDamageInf
player.PrintToChat($" {Localizer["phrases.summary.endline"]}");
}

private Dictionary<int, PlayerDamageInfo> playerDamageInfos = new Dictionary<int, PlayerDamageInfo>();
private readonly Dictionary<int, PlayerDamageInfo> playerDamageInfos = new Dictionary<int, PlayerDamageInfo>();

private class PlayerDamageInfo
{
public Dictionary<int, DamageInfo> GivenDamage = new Dictionary<int, DamageInfo>();
public Dictionary<int, DamageInfo> TakenDamage = new Dictionary<int, DamageInfo>();
public Dictionary<int, DamageInfo> GivenDamage = [];
public Dictionary<int, DamageInfo> TakenDamage = [];
}

private class DamageInfo
Expand All @@ -408,7 +408,7 @@ private class DamageInfo
public int Hits = 0;
}

private Dictionary<int, Dictionary<int, RecentDamage>> recentDamages = new Dictionary<int, Dictionary<int, RecentDamage>>();
private readonly Dictionary<int, Dictionary<int, RecentDamage>> recentDamages = [];

private class RecentDamage
{
Expand Down
38 changes: 19 additions & 19 deletions src/lang/cn.json
Original file line number Diff line number Diff line change
@@ -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._": "未知"
}
"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._": "未知"
}
36 changes: 18 additions & 18 deletions src/lang/en.json
Original file line number Diff line number Diff line change
@@ -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"
}
36 changes: 18 additions & 18 deletions src/lang/pl.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 2252aaa

Please sign in to comment.