Skip to content

Commit 72ee6da

Browse files
committed
Add /b cooldown
1 parent d85b3d4 commit 72ee6da

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

Build/Essentials.dll

1 KB
Binary file not shown.

Build/SignCommands.dll

0 Bytes
Binary file not shown.

Essentials/esConfig.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class esConfig
2323
public string YellowTeamPassword = "";
2424
public string YellowTeamPermission = "essentials.team.yellow";
2525
public List<string> DisableSetHomeInRegions = new List<string>();
26+
public int BackCooldown = 0;
2627

2728
public static string ConfigPath = string.Empty;
2829
public esConfig Write(string path)
@@ -57,7 +58,8 @@ public static void WriteExample(string path)
5758
""YellowTeamPermission"": ""essentials.team.yellow"",
5859
""DisableSetHomeInRegions"": [
5960
""example""
60-
]
61+
],
62+
""BackCooldown"": 0
6163
}");
6264
}
6365

Essentials/esMain.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ public void OnUpdate(EventArgs args)
349349
else if (ePly.SavedBackAction && !ePly.TSPlayer.Dead)
350350
ePly.SavedBackAction = false;
351351

352+
if (ePly.BackCooldown > 0)
353+
ePly.BackCooldown--;
354+
352355
if (ePly.ptTime > -1.0)
353356
{
354357
ePly.ptTime += 60.0;
@@ -608,18 +611,36 @@ private void CMDmoon(CommandArgs args)
608611
private void CMDback(CommandArgs args)
609612
{
610613
var ePly = esPlayers[args.Player.Index];
614+
if (ePly.TSPlayer.Dead)
615+
{
616+
Send.Error(args.Player, "Please wait till you respawn.");
617+
return;
618+
}
619+
if (ePly.BackCooldown > 0)
620+
{
621+
Send.Error(args.Player, "You must wait another {0} seconds before you can use /b again.", ePly.BackCooldown);
622+
return;
623+
}
611624

612625
if (ePly.LastBackAction == BackAction.None)
613626
Send.Error(args.Player, "You do not have a /b position stored.");
614627
else if (ePly.LastBackAction == BackAction.TP)
615628
{
629+
if (Config.BackCooldown > 0 && !args.Player.Group.HasPermission("essentials.back.nocooldown"))
630+
{
631+
ePly.BackCooldown = Config.BackCooldown;
632+
}
616633
args.Player.Teleport(ePly.LastBackX * 16F, ePly.LastBackY * 16F);
617-
Send.Success(args.Player, "Moved you to your position before your last teleport.");
634+
Send.Success(args.Player, "Moved you to your position before you last teleported.");
618635
}
619636
else if (ePly.LastBackAction == BackAction.Death && args.Player.Group.HasPermission("essentials.back.death"))
620637
{
638+
if (Config.BackCooldown > 0 && !args.Player.Group.HasPermission("essentials.back.nocooldown"))
639+
{
640+
ePly.BackCooldown = Config.BackCooldown;
641+
}
621642
args.Player.Teleport(ePly.LastBackX * 16F, ePly.LastBackY * 16F);
622-
Send.Success(args.Player, "Moved you to your position before your last death.");
643+
Send.Success(args.Player, "Moved you to your position before you last died.");
623644
}
624645
else
625646
Send.Error(args.Player, "You do not have permission to /b after death.");

Essentials/esPlayer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class esPlayer
1212
public int LastBackY { get; set; }
1313
public BackAction LastBackAction { get; set; }
1414
public bool SavedBackAction { get; set; }
15+
public int BackCooldown { get; set; }
1516
public List<object> LastSearchResults { get; set; }
1617
public string RedPassword { get; set; }
1718
public string GreenPassword { get; set; }
@@ -37,6 +38,7 @@ public esPlayer(int index)
3738
this.LastBackY = -1;
3839
this.LastBackAction = BackAction.None;
3940
this.SavedBackAction = false;
41+
this.BackCooldown = 0;
4042
this.LastSearchResults = new List<object>();
4143
this.RedPassword = string.Empty;
4244
this.GreenPassword = string.Empty;

0 commit comments

Comments
 (0)