From 1c394c90378d43d1f0992f01ca5c08c8ebeae9c5 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 21 Aug 2011 12:19:34 +0800 Subject: [PATCH] Limit buff time to short's maximum value. --- TShockAPI/Commands.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index d4b8fa26..6ec4200d 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -2434,6 +2434,8 @@ namespace TShockAPI } if (id > 0 && id < Main.maxBuffs) { + if (time < 0 || time > short.MaxValue) + time = 3600; args.Player.SetBuff(id, time); args.Player.SendMessage(string.Format("You have buffed yourself with {0}({1}) for {2} seconds!", Tools.GetBuffName(id), Tools.GetBuffDescription(id), (time / 60)), Color.Green); @@ -2466,7 +2468,7 @@ namespace TShockAPI { if (!int.TryParse(args.Parameters[1], out id)) { - var found = Tools.GetBuffByName(args.Parameters[0]); + var found = Tools.GetBuffByName(args.Parameters[1]); if (found.Count == 0) { args.Player.SendMessage("Invalid buff name!", Color.Red); @@ -2483,9 +2485,13 @@ namespace TShockAPI } if (id > 0 && id < Main.maxBuffs) { - args.Player.SetBuff(id, time); - args.Player.SendMessage(string.Format("You have buffed yourself with {0}({1}) for {2} seconds!", - Tools.GetBuffName(id), Tools.GetBuffDescription(id), (time / 60)), Color.Green); + if (time < 0 || time > short.MaxValue) + time = 3600; + foundplr[0].SetBuff(id, time); + args.Player.SendMessage(string.Format("You have buffed {0} with {1}({2}) for {3} seconds!", + foundplr[0].Name, Tools.GetBuffName(id), Tools.GetBuffDescription(id), (time / 60)), Color.Green); + foundplr[0].SendMessage(string.Format("{0} has buffed you with {1}({2}) for {3} seconds!", + args.Player.Name, Tools.GetBuffName(id), Tools.GetBuffDescription(id), (time / 60)), Color.Green); } else args.Player.SendMessage("Invalid buff ID!", Color.Red);