Skip to content

Commit 5fa3e5e

Browse files
Fix global cooldown and add a warning about cooldowns bypass that admins have
1 parent eb8e70c commit 5fa3e5e

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

Kits/Commands/KitCommand.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public void Execute(IRocketPlayer caller, string[] command)
4848
KitCooldown cooldown;
4949
if (pluginInstance.Configuration.Instance.GlobalCooldown > 0)
5050
{
51-
cooldown = pluginInstance.Cooldowns.OrderByDescending(x => x.Date).FirstOrDefault();
51+
cooldown = pluginInstance.Cooldowns.Where(x => x.SteamId == caller.Id).OrderByDescending(x => x.Date).FirstOrDefault();
52+
5253
if (cooldown != null)
5354
{
5455
TimeSpan timeSpan = cooldown.Date.AddSeconds(pluginInstance.Configuration.Instance.GlobalCooldown) - DateTime.Now;
@@ -78,6 +79,9 @@ public void Execute(IRocketPlayer caller, string[] command)
7879
EndDate = DateTime.Now.AddSeconds(kit.Cooldown)
7980
};
8081
pluginInstance.Cooldowns.Add(cooldown);
82+
} else
83+
{
84+
pluginInstance.SendMessageToPlayer(caller, "KitAdminBypassPermission");
8185
}
8286

8387
UnturnedPlayer player;

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.2</Version>
7+
<Version>1.0.3</Version>
88
</PropertyGroup>
99

1010
<ItemGroup>

Kits/KitsPlugin.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ protected override void Unload()
8888
{ "DayShort", "{0}d" },
8989
{ "HourShort", "{0}h" },
9090
{ "MinuteShort", "{0}m" },
91-
{ "SecondShort", "{0}s" }
91+
{ "SecondShort", "{0}s" },
92+
{ "KitAdminBypassPermission", "You have bypassed kit cooldown, because you are admin or have kits.admin permission." }
9293
};
9394

9495
private void OnPostSave()

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Create kits with custom items, cooldown, price, experience and vehicle.
99
* Global cooldown prevents players from using kits too often.
1010
* Kits are saved in XML file and can be easily edited. Remember to reload the configuration after editing the file.
1111

12+
> **Note:** Admins bypass cooldowns and can use kits without any restrictions. Do not give `kits.admin` permission to normal players.
13+
1214
## Commands
1315
* `/kit <name>` - Use the kit.
1416
* `/kit <name> <player>` - Give the kit to another player. Requires `givekit` permission.
@@ -71,17 +73,21 @@ To grant access to the kit, add the permission `kit.<name>` to the player. For e
7173
```xml
7274
<?xml version="1.0" encoding="utf-8"?>
7375
<Translations xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
74-
<Translation Id="KitCommandSyntax" Value="You must specify kit name." />
76+
<Translation Id="KitCommandSyntax" Value="You must specify kit name. Use [[b]]/kits[[/b]] to see the list of available kits." />
7577
<Translation Id="KitCommandConsoleSyntax" Value="You must specify kit name and player you want to receive the kit." />
7678
<Translation Id="KitNotFound" Value="Kit [[b]]{0}[[/b]] not found." />
7779
<Translation Id="KitGlobalCooldown" Value="You have to wait [[b]]{0}[[/b]] before using any kit again." />
7880
<Translation Id="KitCooldown" Value="You have to wait [[b]]{0}[[/b]] before using kit [[b]]{1}[[/b]] again." />
81+
<Translation Id="KitNotEnoughMoney" Value="You can't afford to buy this kit for [[b]]${0}[[/b]] credits." />
7982
<Translation Id="KitReceived" Value="You received kit [[b]]{0}[[/b]]." />
83+
<Translation Id="KitReceivedFromSomeone" Value="You received kit [[b]]{0}[[/b]] from [[b]]{1}[[/b]]." />
84+
<Translation Id="KitGiven" Value="You have given kit [[b]]{0}[[/b]] to [[b]]{1}[[/b]]." />
8085
<Translation Id="KitAlreadyExists" Value="Kit [[b]]{0}[[/b]] already exists." />
81-
<Translation Id="CreateKitCommandSyntax" Value="Use the following format: /ckit [[name]] [[cooldown]] [price] [experience] [vehicle]" />
86+
<Translation Id="CreateKitCommandSyntax" Value="Usage: /ckit [[name]] [[cooldown]] [price] [experience] [vehicle]" />
8287
<Translation Id="CreateKitNameInvalid" Value="Name must contain no special characters. [[b]]{0}[[/b]] is invalid." />
8388
<Translation Id="CreateKitCooldownNotNumber" Value="Cooldown must be a number. [[b]]{0}[[/b]] is invalid." />
8489
<Translation Id="CreateKitPriceNotNumber" Value="Price must be a number. [[b]]{0}[[/b]] is invalid." />
90+
<Translation Id="CreateKitUconomyNotInstalled" Value="You must install Uconomy plugin to create kits with prices." />
8591
<Translation Id="CreateKitExperienceNotNumber" Value="Experience must be a number. [[b]]{0}[[/b]] is invalid." />
8692
<Translation Id="CreateKitVehicleNotFound" Value="Vehicle [[b]]{0}[[/b]] not found." />
8793
<Translation Id="KitCreated" Value="Created kit [[b]]{0}[[/b]] with [[b]]{1}[[/b]] cooldown and [[b]]{2}[[/b]] items." />
@@ -92,6 +98,7 @@ To grant access to the kit, add the permission `kit.<name>` to the player. For e
9298
<Translation Id="KitsAvailable" Value="Your kits: {0}" />
9399
<Translation Id="DeleteKitCommandSyntax" Value="You must specify kit name." />
94100
<Translation Id="KitDeleted" Value="Deleted kit [[b]]{0}[[/b]]." />
101+
<Translation Id="KitNoPermission" Value="You don't have permission to use kit [[b]]{0}[[/b]]." />
95102
<Translation Id="KitOtherNoPermission" Value="You don't have permission to give kit to other players." />
96103
<Translation Id="PlayerNotFound" Value="Player {0} not found." />
97104
<Translation Id="Day" Value="1 day" />
@@ -107,9 +114,6 @@ To grant access to the kit, add the permission `kit.<name>` to the player. For e
107114
<Translation Id="HourShort" Value="{0}h" />
108115
<Translation Id="MinuteShort" Value="{0}m" />
109116
<Translation Id="SecondShort" Value="{0}s" />
110-
<Translation Id="KitReceivedFromSomeone" Value="You received kit [[b]]{0}[[/b]] from [[b]]{1}[[/b]]." />
111-
<Translation Id="KitGiven" Value="You have given kit [[b]]{0}[[/b]] to [[b]]{1}[[/b]]." />
112-
<Translation Id="KitNotEnoughMoney" Value="You can't afford to buy this kit for [[b]]${0}[[/b]] credits." />
113-
<Translation Id="CreateKitUconomyNotInstalled" Value="You must install Uconomy plugin to create kits with prices." />
117+
<Translation Id="KitAdminBypassPermission" Value="You have bypassed kit cooldown, because you are admin or have kits.admin permission." />
114118
</Translations>
115119
```

0 commit comments

Comments
 (0)