Skip to content

Commit

Permalink
Add /b cooldown
Browse files Browse the repository at this point in the history
  • Loading branch information
Scavenger3 committed Oct 9, 2013
1 parent d85b3d4 commit 72ee6da
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
Binary file modified Build/Essentials.dll
Binary file not shown.
Binary file modified Build/SignCommands.dll
Binary file not shown.
4 changes: 3 additions & 1 deletion Essentials/esConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class esConfig
public string YellowTeamPassword = "";
public string YellowTeamPermission = "essentials.team.yellow";
public List<string> DisableSetHomeInRegions = new List<string>();
public int BackCooldown = 0;

public static string ConfigPath = string.Empty;
public esConfig Write(string path)
Expand Down Expand Up @@ -57,7 +58,8 @@ public static void WriteExample(string path)
""YellowTeamPermission"": ""essentials.team.yellow"",
""DisableSetHomeInRegions"": [
""example""
]
],
""BackCooldown"": 0
}");
}

Expand Down
25 changes: 23 additions & 2 deletions Essentials/esMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ public void OnUpdate(EventArgs args)
else if (ePly.SavedBackAction && !ePly.TSPlayer.Dead)
ePly.SavedBackAction = false;

if (ePly.BackCooldown > 0)
ePly.BackCooldown--;

if (ePly.ptTime > -1.0)
{
ePly.ptTime += 60.0;
Expand Down Expand Up @@ -608,18 +611,36 @@ private void CMDmoon(CommandArgs args)
private void CMDback(CommandArgs args)
{
var ePly = esPlayers[args.Player.Index];
if (ePly.TSPlayer.Dead)
{
Send.Error(args.Player, "Please wait till you respawn.");
return;
}
if (ePly.BackCooldown > 0)
{
Send.Error(args.Player, "You must wait another {0} seconds before you can use /b again.", ePly.BackCooldown);
return;
}

if (ePly.LastBackAction == BackAction.None)
Send.Error(args.Player, "You do not have a /b position stored.");
else if (ePly.LastBackAction == BackAction.TP)
{
if (Config.BackCooldown > 0 && !args.Player.Group.HasPermission("essentials.back.nocooldown"))
{
ePly.BackCooldown = Config.BackCooldown;
}
args.Player.Teleport(ePly.LastBackX * 16F, ePly.LastBackY * 16F);
Send.Success(args.Player, "Moved you to your position before your last teleport.");
Send.Success(args.Player, "Moved you to your position before you last teleported.");
}
else if (ePly.LastBackAction == BackAction.Death && args.Player.Group.HasPermission("essentials.back.death"))
{
if (Config.BackCooldown > 0 && !args.Player.Group.HasPermission("essentials.back.nocooldown"))
{
ePly.BackCooldown = Config.BackCooldown;
}
args.Player.Teleport(ePly.LastBackX * 16F, ePly.LastBackY * 16F);
Send.Success(args.Player, "Moved you to your position before your last death.");
Send.Success(args.Player, "Moved you to your position before you last died.");
}
else
Send.Error(args.Player, "You do not have permission to /b after death.");
Expand Down
2 changes: 2 additions & 0 deletions Essentials/esPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class esPlayer
public int LastBackY { get; set; }
public BackAction LastBackAction { get; set; }
public bool SavedBackAction { get; set; }
public int BackCooldown { get; set; }
public List<object> LastSearchResults { get; set; }
public string RedPassword { get; set; }
public string GreenPassword { get; set; }
Expand All @@ -37,6 +38,7 @@ public esPlayer(int index)
this.LastBackY = -1;
this.LastBackAction = BackAction.None;
this.SavedBackAction = false;
this.BackCooldown = 0;
this.LastSearchResults = new List<object>();
this.RedPassword = string.Empty;
this.GreenPassword = string.Empty;
Expand Down

0 comments on commit 72ee6da

Please sign in to comment.