From 5fa3e5e550279df3ab5eab6f10c568f3bfefa34b Mon Sep 17 00:00:00 2001 From: MCrow Date: Thu, 2 Jan 2025 10:12:28 +0100 Subject: [PATCH] Fix global cooldown and add a warning about cooldowns bypass that admins have --- Kits/Commands/KitCommand.cs | 6 +++++- Kits/Kits.csproj | 2 +- Kits/KitsPlugin.cs | 3 ++- README.md | 16 ++++++++++------ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Kits/Commands/KitCommand.cs b/Kits/Commands/KitCommand.cs index 4d59807..6f8581c 100644 --- a/Kits/Commands/KitCommand.cs +++ b/Kits/Commands/KitCommand.cs @@ -48,7 +48,8 @@ public void Execute(IRocketPlayer caller, string[] command) KitCooldown cooldown; if (pluginInstance.Configuration.Instance.GlobalCooldown > 0) { - cooldown = pluginInstance.Cooldowns.OrderByDescending(x => x.Date).FirstOrDefault(); + cooldown = pluginInstance.Cooldowns.Where(x => x.SteamId == caller.Id).OrderByDescending(x => x.Date).FirstOrDefault(); + if (cooldown != null) { TimeSpan timeSpan = cooldown.Date.AddSeconds(pluginInstance.Configuration.Instance.GlobalCooldown) - DateTime.Now; @@ -78,6 +79,9 @@ public void Execute(IRocketPlayer caller, string[] command) EndDate = DateTime.Now.AddSeconds(kit.Cooldown) }; pluginInstance.Cooldowns.Add(cooldown); + } else + { + pluginInstance.SendMessageToPlayer(caller, "KitAdminBypassPermission"); } UnturnedPlayer player; diff --git a/Kits/Kits.csproj b/Kits/Kits.csproj index f5eba00..2e6495e 100644 --- a/Kits/Kits.csproj +++ b/Kits/Kits.csproj @@ -4,7 +4,7 @@ net48 latest RestoreMonarchy.Kits - 1.0.2 + 1.0.3 diff --git a/Kits/KitsPlugin.cs b/Kits/KitsPlugin.cs index 9ad3d9f..2a58410 100644 --- a/Kits/KitsPlugin.cs +++ b/Kits/KitsPlugin.cs @@ -88,7 +88,8 @@ protected override void Unload() { "DayShort", "{0}d" }, { "HourShort", "{0}h" }, { "MinuteShort", "{0}m" }, - { "SecondShort", "{0}s" } + { "SecondShort", "{0}s" }, + { "KitAdminBypassPermission", "You have bypassed kit cooldown, because you are admin or have kits.admin permission." } }; private void OnPostSave() diff --git a/README.md b/README.md index 5f07587..04fd22d 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ Create kits with custom items, cooldown, price, experience and vehicle. * Global cooldown prevents players from using kits too often. * Kits are saved in XML file and can be easily edited. Remember to reload the configuration after editing the file. +> **Note:** Admins bypass cooldowns and can use kits without any restrictions. Do not give `kits.admin` permission to normal players. + ## Commands * `/kit ` - Use the kit. * `/kit ` - Give the kit to another player. Requires `givekit` permission. @@ -71,17 +73,21 @@ To grant access to the kit, add the permission `kit.` to the player. For e ```xml - + + + + - + + @@ -92,6 +98,7 @@ To grant access to the kit, add the permission `kit.` to the player. For e + @@ -107,9 +114,6 @@ To grant access to the kit, add the permission `kit.` to the player. For e - - - - + ``` \ No newline at end of file