Skip to content

Commit 5803cd2

Browse files
committed
Release v1.0.38
1 parent 4321b27 commit 5803cd2

39 files changed

+485
-430
lines changed

CHANGELOG

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# 2025.02.24 - 1.0.38
2+
3+
- feat: Enhanced rank point commands to support offline targeting via SteamID
4+
- feat: Introduced the banip command in the bans module
5+
- feat: Updated the Toplists module to return only the TOPx clantag based on the defined maximum value
6+
- feat: Added a configuration option for CustomTag removal delay to improve compatibility
7+
- optimise: Eliminated redundant task assignment operators from Task.Run calls
8+
- fix: Corrected improper usage of the shared API within the bans module
9+
- fix: Prevented an infinite retry loop when a disconnected player's data fails to load
10+
- fix: Resolved the premature "player not yet loaded" error log in the bans module
11+
- chore: Relocated the top clantag translation functionality to the TopLists module
12+
113
# 2025.02.01 - 1.0.37
214

315
- feat: Enhanced module reset functionality with unique module identifiers for future compatibility

modules/custom-tags/K4-Zenith-CustomTags.cs

+53-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class Plugin : BasePlugin
2525

2626
public override string ModuleName => $"K4-Zenith | {MODULE_ID}";
2727
public override string ModuleAuthor => "K4ryuu @ KitsuneLab";
28-
public override string ModuleVersion => "1.0.9";
28+
public override string ModuleVersion => "1.0.10";
2929

3030
private PlayerCapability<IPlayerServices>? _playerServicesCapability;
3131
private PluginCapability<IModuleServices>? _moduleServicesCapability;
@@ -34,6 +34,7 @@ public class Plugin : BasePlugin
3434
private IModuleServices? _moduleServices;
3535

3636
private readonly Dictionary<CCSPlayerController, IPlayerServices> _playerCache = [];
37+
private readonly Dictionary<CCSPlayerController, CounterStrikeSharp.API.Modules.Timers.Timer> _removalTimers = [];
3738

3839
public KitsuneMenu Menu { get; private set; } = null!;
3940
public IModuleConfigAccessor _coreAccessor = null!;
@@ -81,9 +82,11 @@ public override void OnAllPluginsLoaded(bool hotReload)
8182

8283
_moduleServices!.RegisterModuleStorage(new Dictionary<string, object?>
8384
{
84-
{ "ChoosenTag", "Default" },
85+
{ "ChoosenTag", "Default" }
8586
});
8687

88+
_moduleServices?.RegisterModuleConfig("Config", "TagRemovalDelay", "Delay in seconds before removing tags when permissions are lost (0 to disable)", 5.0f);
89+
8790
EnsureConfigFileExists();
8891
EnsurePredefinedConfigFileExists();
8992

@@ -447,6 +450,12 @@ private void ApplyTagConfig(CCSPlayerController player)
447450

448451
string choosenTag = zenithPlayer.GetStorage<string>("ChoosenTag") ?? "Default";
449452

453+
if (_removalTimers.TryGetValue(player, out var existingTimer))
454+
{
455+
existingTimer.Kill();
456+
_removalTimers.Remove(player);
457+
}
458+
450459
if (choosenTag == "None")
451460
{
452461
ApplyNullConfig(zenithPlayer);
@@ -467,7 +476,24 @@ private void ApplyTagConfig(CCSPlayerController player)
467476

468477
if (!existsForUser)
469478
{
470-
zenithPlayer.SetStorage("ChoosenTag", "Default");
479+
float removalDelay = _coreAccessor.GetValue<float>("Config", "TagRemovalDelay");
480+
if (removalDelay > 0)
481+
{
482+
_removalTimers[player] = AddTimer(removalDelay, () =>
483+
{
484+
if (!CheckTagAvailability(player, choosenTag))
485+
{
486+
zenithPlayer.SetStorage("ChoosenTag", "Default");
487+
ApplyTagConfig(player);
488+
_removalTimers.Remove(player);
489+
}
490+
});
491+
return;
492+
}
493+
else
494+
{
495+
zenithPlayer.SetStorage("ChoosenTag", "Default");
496+
}
471497
}
472498
else
473499
return;
@@ -531,6 +557,20 @@ private void ApplyTagConfig(CCSPlayerController player)
531557
}
532558
}
533559

560+
private bool CheckTagAvailability(CCSPlayerController player, string tagName)
561+
{
562+
if (_tagConfigs == null) return false;
563+
564+
foreach (var kvp in _tagConfigs)
565+
{
566+
if (CheckPermissionOrSteamID(player, kvp.Key) && kvp.Value.AvailableConfigs != null && kvp.Value.AvailableConfigs.Contains(tagName))
567+
{
568+
return true;
569+
}
570+
}
571+
return false;
572+
}
573+
534574
private static bool HasTagConfigValues(TagConfig config)
535575
{
536576
return !string.IsNullOrEmpty(config.ChatColor) ||
@@ -616,11 +656,21 @@ private void OnZenithPlayerLoaded(CCSPlayerController player)
616656

617657
private void OnZenithPlayerUnloaded(CCSPlayerController player)
618658
{
659+
if (_removalTimers.TryGetValue(player, out var timer))
660+
{
661+
timer.Kill();
662+
_removalTimers.Remove(player);
663+
}
619664
_playerCache.Remove(player);
620665
}
621666

622667
public override void Unload(bool hotReload)
623668
{
669+
foreach (var timer in _removalTimers.Values)
670+
{
671+
timer.Kill();
672+
}
673+
_removalTimers.Clear();
624674
_playerCache.Clear();
625675

626676
_moduleServicesCapability?.Get()?.DisposeModule(this.GetType().Assembly);

modules/custom-tags/K4-Zenith-CustomTags.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</ItemGroup>
2727
<ItemGroup>
2828
<Reference Include="KitsuneMenu">
29-
<HintPath>/Users/sples/Projects/CS2_Random/Menu-main/src/bin/Release/net8.0/publish/KitsuneMenu.dll</HintPath>
29+
<HintPath>/Users/sples/Projects/CS2_Random/Menu-main/src/bin/KitsuneMenu/shared/KitsuneMenu/KitsuneMenu.dll</HintPath>
3030
<Private>false</Private>
3131
</Reference>
3232
</ItemGroup>

modules/ranks/Commands.cs

+90-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
using CounterStrikeSharp.API;
32
using CounterStrikeSharp.API.Core;
43
using CounterStrikeSharp.API.Core.Translations;
@@ -101,13 +100,6 @@ public void OnRankCommand(CCSPlayerController? player, CommandInfo info)
101100

102101
private void ProcessTargetAction(CCSPlayerController? player, CommandInfo info, Func<IPlayerServices, long?, (string message, string logMessage)> action, bool requireAmount = true)
103102
{
104-
TargetResult targets = info.GetArgTargetResult(1);
105-
if (!targets.Any())
106-
{
107-
_moduleServices?.PrintForPlayer(player, Localizer.ForPlayer(player, "k4.phrases.no-target"));
108-
return;
109-
}
110-
111103
long? amount = null;
112104
if (requireAmount)
113105
{
@@ -119,6 +111,13 @@ private void ProcessTargetAction(CCSPlayerController? player, CommandInfo info,
119111
amount = parsedAmount;
120112
}
121113

114+
TargetResult targets = info.GetArgTargetResult(1);
115+
if (!targets.Any())
116+
{
117+
_moduleServices?.PrintForPlayer(player, Localizer.ForPlayer(player, "k4.phrases.no-target"));
118+
return;
119+
}
120+
122121
foreach (var target in targets)
123122
{
124123
if (_playerCache.TryGetValue(target, out var zenithPlayer))
@@ -138,8 +137,55 @@ private void ProcessTargetAction(CCSPlayerController? player, CommandInfo info,
138137
}
139138
}
140139

140+
private void ProcessOfflineTargetAction(ulong steamID, char operatation, long amount)
141+
{
142+
if (_moduleServices == null)
143+
return;
144+
145+
Task.Run(async () =>
146+
{
147+
long points = await _moduleServices.GetOfflineData<long>(steamID, "storage", "Points");
148+
switch (operatation)
149+
{
150+
case '+':
151+
points += amount;
152+
break;
153+
case '-':
154+
points -= amount;
155+
break;
156+
case '=':
157+
points = amount;
158+
break;
159+
}
160+
161+
if (points < 0)
162+
points = 0;
163+
164+
string rank = DetermineRanks(points).CurrentRank?.Name ?? "k4.phrases.rank.none";
165+
await _moduleServices.SetOfflineData(steamID, "storage", new Dictionary<string, object?> { { "Points", points }, { "Rank", rank } });
166+
});
167+
}
168+
141169
public void OnGivePoints(CCSPlayerController? player, CommandInfo info)
142170
{
171+
if (ulong.TryParse(info.GetArg(1), out ulong steamId))
172+
{
173+
if (!int.TryParse(info.GetArg(2), out int amount) || amount <= 0)
174+
{
175+
_moduleServices?.PrintForPlayer(player, Localizer.ForPlayer(player, "k4.phrases.invalid-amount"));
176+
return;
177+
}
178+
179+
var target = Utilities.GetPlayerFromSteamId(steamId);
180+
if (target == null)
181+
{
182+
ProcessOfflineTargetAction(steamId, '+', amount);
183+
Logger.LogWarning("{0} ({1}) gave {2} {3} rank points [OFFLINE]",
184+
player?.PlayerName ?? "CONSOLE", player?.SteamID ?? 0, steamId, amount);
185+
return;
186+
}
187+
}
188+
143189
ProcessTargetAction(player, info,
144190
(zenithPlayer, amount) =>
145191
{
@@ -158,6 +204,24 @@ public void OnGivePoints(CCSPlayerController? player, CommandInfo info)
158204

159205
public void OnTakePoints(CCSPlayerController? player, CommandInfo info)
160206
{
207+
if (ulong.TryParse(info.GetArg(1), out ulong steamId))
208+
{
209+
if (!int.TryParse(info.GetArg(2), out int amount) || amount <= 0)
210+
{
211+
_moduleServices?.PrintForPlayer(player, Localizer.ForPlayer(player, "k4.phrases.invalid-amount"));
212+
return;
213+
}
214+
215+
var target = Utilities.GetPlayerFromSteamId(steamId);
216+
if (target == null)
217+
{
218+
ProcessOfflineTargetAction(steamId, '-', amount);
219+
Logger.LogWarning("{0} ({1}) took {2} rank points from {3} [OFFLINE]",
220+
player?.PlayerName ?? "CONSOLE", player?.SteamID ?? 0, amount, steamId);
221+
return;
222+
}
223+
}
224+
161225
ProcessTargetAction(player, info,
162226
(zenithPlayer, amount) =>
163227
{
@@ -176,6 +240,24 @@ public void OnTakePoints(CCSPlayerController? player, CommandInfo info)
176240

177241
public void OnSetPoints(CCSPlayerController? player, CommandInfo info)
178242
{
243+
if (ulong.TryParse(info.GetArg(1), out ulong steamId))
244+
{
245+
if (!int.TryParse(info.GetArg(2), out int amount) || amount <= 0)
246+
{
247+
_moduleServices?.PrintForPlayer(player, Localizer.ForPlayer(player, "k4.phrases.invalid-amount"));
248+
return;
249+
}
250+
251+
var target = Utilities.GetPlayerFromSteamId(steamId);
252+
if (target == null)
253+
{
254+
ProcessOfflineTargetAction(steamId, '=', amount);
255+
Logger.LogWarning("{0} ({1}) set {2}'s rank points to {3} [OFFLINE]",
256+
player?.PlayerName ?? "CONSOLE", player?.SteamID ?? 0, steamId, amount);
257+
return;
258+
}
259+
}
260+
179261
ProcessTargetAction(player, info,
180262
(zenithPlayer, amount) =>
181263
{

modules/ranks/K4-Zenith-Ranks.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public sealed partial class Plugin : BasePlugin
2121

2222
public override string ModuleName => $"K4-Zenith | {MODULE_ID}";
2323
public override string ModuleAuthor => "K4ryuu @ KitsuneLab";
24-
public override string ModuleVersion => "1.0.16";
24+
public override string ModuleVersion => "1.0.17";
2525

2626
private PlayerCapability<IPlayerServices>? _playerServicesCapability;
2727
private PluginCapability<IModuleServices>? _moduleServicesCapability;

modules/ranks/K4-Zenith-Ranks.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</ItemGroup>
2828
<ItemGroup>
2929
<Reference Include="KitsuneMenu">
30-
<HintPath>/Users/sples/Projects/CS2_Random/Menu-main/src/bin/Release/net8.0/publish/KitsuneMenu.dll</HintPath>
30+
<HintPath>/Users/sples/Projects/CS2_Random/Menu-main/src/bin/KitsuneMenu/shared/KitsuneMenu/KitsuneMenu.dll</HintPath>
3131
<Private>false</Private>
3232
</Reference>
3333
</ItemGroup>

modules/statistics/K4-Zenith-Stats.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class Plugin : BasePlugin
2626

2727
public override string ModuleName => $"K4-Zenith | {MODULE_ID}";
2828
public override string ModuleAuthor => "K4ryuu @ KitsuneLab";
29-
public override string ModuleVersion => "1.0.7";
29+
public override string ModuleVersion => "1.0.8";
3030

3131
public KitsuneMenu Menu { get; private set; } = null!;
3232
private PlayerCapability<IPlayerServices>? _playerServicesCapability;
@@ -273,7 +273,7 @@ private void OnMapStart(string mapName)
273273

274274
private void OnMapEnd()
275275
{
276-
_ = Task.Run(async () =>
276+
Task.Run(async () =>
277277
{
278278
foreach (var playerStats in _playerStats.Values)
279279
{
@@ -995,7 +995,7 @@ public PlayerStats(IPlayerServices player, Plugin plugin)
995995
if (_plugin._moduleServices == null)
996996
return;
997997

998-
_ = Task.Run(async () =>
998+
Task.Run(async () =>
999999
{
10001000
await LoadCurrentMapStats(_plugin._moduleServices);
10011001
await LoadWeaponStats(_plugin._moduleServices);

modules/statistics/K4-Zenith-Stats.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</ItemGroup>
2929
<ItemGroup>
3030
<Reference Include="KitsuneMenu">
31-
<HintPath>/Users/sples/Projects/CS2_Random/Menu-main/src/bin/Release/net8.0/publish/KitsuneMenu.dll</HintPath>
31+
<HintPath>/Users/sples/Projects/CS2_Random/Menu-main/src/bin/KitsuneMenu/shared/KitsuneMenu/KitsuneMenu.dll</HintPath>
3232
<Private>false</Private>
3333
</Reference>
3434
</ItemGroup>

0 commit comments

Comments
 (0)