Skip to content

Commit 2432684

Browse files
Fix infinite kits bug IMPORTANT UPDATE!
1 parent 5fa3e5e commit 2432684

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

Kits/Commands/KitCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void Execute(IRocketPlayer caller, string[] command)
6262
}
6363
}
6464

65-
cooldown = pluginInstance.Cooldowns.Find(x => x.SteamId == caller.Id && x.KitName.Equals(kit.Name, StringComparison.OrdinalIgnoreCase));
65+
cooldown = pluginInstance.GetCooldown(caller.Id, kitName);
6666
if (cooldown != null && cooldown.EndDate > DateTime.Now)
6767
{
6868
TimeSpan timeSpan = cooldown.EndDate - DateTime.Now;

Kits/Commands/KitsCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void Execute(IRocketPlayer caller, string[] command)
3636
{
3737
string kitName = pluginInstance.Translate("KitNameFormat", kit.Name);
3838
string kitPrice = kit.Price > 0 ? pluginInstance.Translate("KitPriceFormat", kit.Price) : "";
39-
KitCooldown cooldown = pluginInstance.Cooldowns.Find(x => x.SteamId == caller.Id && x.KitName.Equals(kit.Name, System.StringComparison.OrdinalIgnoreCase));
39+
KitCooldown cooldown = pluginInstance.GetCooldown(caller.Id, kit.Name);
4040
string kitCooldown = "";
4141
if (cooldown != null && !hasKitAdmin && cooldown.EndDate > DateTime.Now)
4242
{

Kits/Kits.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net48</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
<RootNamespace>RestoreMonarchy.Kits</RootNamespace>
7-
<Version>1.0.3</Version>
7+
<Version>1.0.5</Version>
88
</PropertyGroup>
99

1010
<ItemGroup>

Kits/KitsPlugin.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,21 @@ protected override void Unload()
9292
{ "KitAdminBypassPermission", "You have bypassed kit cooldown, because you are admin or have kits.admin permission." }
9393
};
9494

95+
public KitCooldown GetCooldown(string steamId, string kitName)
96+
{
97+
Cooldowns.RemoveAll(x => x.EndDate < DateTime.Now);
98+
99+
return Cooldowns.Find(x => x.SteamId == steamId && x.KitName.Equals(kitName, StringComparison.OrdinalIgnoreCase));
100+
}
101+
95102
private void OnPostSave()
96103
{
97104
KitCooldownsDatabase.Save();
98105
}
99106

100107
public string FormatTimespan(TimeSpan span)
101108
{
102-
if (span <= TimeSpan.Zero) return Translate("Zero");
109+
if (span < TimeSpan.FromSeconds(1)) return Translate("Zero");
103110

104111
List<string> items = new();
105112
if (span.Days > 0)

0 commit comments

Comments
 (0)