Skip to content

Commit

Permalink
Fix global cooldown and add a warning about cooldowns bypass that adm…
Browse files Browse the repository at this point in the history
…ins have
  • Loading branch information
RestoreMonarchy committed Jan 2, 2025
1 parent eb8e70c commit 5fa3e5e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Kits/Commands/KitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Kits/Kits.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net48</TargetFramework>
<LangVersion>latest</LangVersion>
<RootNamespace>RestoreMonarchy.Kits</RootNamespace>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Kits/KitsPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <name>` - Use the kit.
* `/kit <name> <player>` - Give the kit to another player. Requires `givekit` permission.
Expand Down Expand Up @@ -71,17 +73,21 @@ To grant access to the kit, add the permission `kit.<name>` to the player. For e
```xml
<?xml version="1.0" encoding="utf-8"?>
<Translations xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Translation Id="KitCommandSyntax" Value="You must specify kit name." />
<Translation Id="KitCommandSyntax" Value="You must specify kit name. Use [[b]]/kits[[/b]] to see the list of available kits." />
<Translation Id="KitCommandConsoleSyntax" Value="You must specify kit name and player you want to receive the kit." />
<Translation Id="KitNotFound" Value="Kit [[b]]{0}[[/b]] not found." />
<Translation Id="KitGlobalCooldown" Value="You have to wait [[b]]{0}[[/b]] before using any kit again." />
<Translation Id="KitCooldown" Value="You have to wait [[b]]{0}[[/b]] before using kit [[b]]{1}[[/b]] again." />
<Translation Id="KitNotEnoughMoney" Value="You can't afford to buy this kit for [[b]]${0}[[/b]] credits." />
<Translation Id="KitReceived" Value="You received kit [[b]]{0}[[/b]]." />
<Translation Id="KitReceivedFromSomeone" Value="You received kit [[b]]{0}[[/b]] from [[b]]{1}[[/b]]." />
<Translation Id="KitGiven" Value="You have given kit [[b]]{0}[[/b]] to [[b]]{1}[[/b]]." />
<Translation Id="KitAlreadyExists" Value="Kit [[b]]{0}[[/b]] already exists." />
<Translation Id="CreateKitCommandSyntax" Value="Use the following format: /ckit [[name]] [[cooldown]] [price] [experience] [vehicle]" />
<Translation Id="CreateKitCommandSyntax" Value="Usage: /ckit [[name]] [[cooldown]] [price] [experience] [vehicle]" />
<Translation Id="CreateKitNameInvalid" Value="Name must contain no special characters. [[b]]{0}[[/b]] is invalid." />
<Translation Id="CreateKitCooldownNotNumber" Value="Cooldown must be a number. [[b]]{0}[[/b]] is invalid." />
<Translation Id="CreateKitPriceNotNumber" Value="Price must be a number. [[b]]{0}[[/b]] is invalid." />
<Translation Id="CreateKitUconomyNotInstalled" Value="You must install Uconomy plugin to create kits with prices." />
<Translation Id="CreateKitExperienceNotNumber" Value="Experience must be a number. [[b]]{0}[[/b]] is invalid." />
<Translation Id="CreateKitVehicleNotFound" Value="Vehicle [[b]]{0}[[/b]] not found." />
<Translation Id="KitCreated" Value="Created kit [[b]]{0}[[/b]] with [[b]]{1}[[/b]] cooldown and [[b]]{2}[[/b]] items." />
Expand All @@ -92,6 +98,7 @@ To grant access to the kit, add the permission `kit.<name>` to the player. For e
<Translation Id="KitsAvailable" Value="Your kits: {0}" />
<Translation Id="DeleteKitCommandSyntax" Value="You must specify kit name." />
<Translation Id="KitDeleted" Value="Deleted kit [[b]]{0}[[/b]]." />
<Translation Id="KitNoPermission" Value="You don't have permission to use kit [[b]]{0}[[/b]]." />
<Translation Id="KitOtherNoPermission" Value="You don't have permission to give kit to other players." />
<Translation Id="PlayerNotFound" Value="Player {0} not found." />
<Translation Id="Day" Value="1 day" />
Expand All @@ -107,9 +114,6 @@ To grant access to the kit, add the permission `kit.<name>` to the player. For e
<Translation Id="HourShort" Value="{0}h" />
<Translation Id="MinuteShort" Value="{0}m" />
<Translation Id="SecondShort" Value="{0}s" />
<Translation Id="KitReceivedFromSomeone" Value="You received kit [[b]]{0}[[/b]] from [[b]]{1}[[/b]]." />
<Translation Id="KitGiven" Value="You have given kit [[b]]{0}[[/b]] to [[b]]{1}[[/b]]." />
<Translation Id="KitNotEnoughMoney" Value="You can't afford to buy this kit for [[b]]${0}[[/b]] credits." />
<Translation Id="CreateKitUconomyNotInstalled" Value="You must install Uconomy plugin to create kits with prices." />
<Translation Id="KitAdminBypassPermission" Value="You have bypassed kit cooldown, because you are admin or have kits.admin permission." />
</Translations>
```

0 comments on commit 5fa3e5e

Please sign in to comment.