From 4886f693d1a6864255a9c1cca37844337dc2352e Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 12 Sep 2017 19:05:00 +1000 Subject: [PATCH] Prevent spamming /team invite --- MCGalaxy/Commands/Fun/CmdTeam.cs | 11 ++++++++++- MCGalaxy/Player/Player.Fields.cs | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/MCGalaxy/Commands/Fun/CmdTeam.cs b/MCGalaxy/Commands/Fun/CmdTeam.cs index 931bd5b05..3d241b2b6 100644 --- a/MCGalaxy/Commands/Fun/CmdTeam.cs +++ b/MCGalaxy/Commands/Fun/CmdTeam.cs @@ -153,7 +153,16 @@ namespace MCGalaxy.Commands.Fun { Player.Message(p, "You need to provide the name of the person to invite."); return; } Player who = PlayerInfo.FindMatches(p, args[1]); - if (who == null) return; + if (who == null) return; + + DateTime cooldown = p.NextTeamInvite; + DateTime now = DateTime.UtcNow; + if (now < cooldown) { + Player.Message(p, "You can invite a player to join your team in another {0} seconds", + (int)(cooldown - now).TotalSeconds); + return; + } + p.NextTeamInvite = now.AddSeconds(5); Player.Message(p, "Invited " + who.ColoredName + " %Sto join your team."); Player.Message(who, p.ColoredName + " %Sinvited you to join the " + team.Color + team.Name + " %Steam."); diff --git a/MCGalaxy/Player/Player.Fields.cs b/MCGalaxy/Player/Player.Fields.cs index e4ca4aa54..ce46055b0 100644 --- a/MCGalaxy/Player/Player.Fields.cs +++ b/MCGalaxy/Player/Player.Fields.cs @@ -83,7 +83,7 @@ namespace MCGalaxy { public string titlecolor = ""; public int passtries = 0; public bool hasreadrules; - public DateTime NextReviewTime, NextEat; + public DateTime NextReviewTime, NextEat, NextTeamInvite; public float ReachDistance = 5; public bool hackrank; public bool SuperUser;