diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 601c2591..bf2db430 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -531,7 +531,7 @@ namespace TShockAPI add(new Command(Permissions.buff, Buff, "buff") { AllowServer = false, - HelpText = "Gives yourself a buff for an amount of time." + HelpText = "Gives yourself a buff or debuff for an amount of time. Putting -1 for time will set it to 415 days." }); add(new Command(Permissions.clear, Clear, "clear") { @@ -539,7 +539,7 @@ namespace TShockAPI }); add(new Command(Permissions.buffplayer, GBuff, "gbuff", "buffplayer") { - HelpText = "Gives another player a buff for an amount of time." + HelpText = "Gives another player a buff or debuff for an amount of time. Putting -1 for time will set it to 415 days." }); add(new Command(Permissions.godmode, ToggleGodMode, "godmode") { @@ -5961,11 +5961,12 @@ namespace TShockAPI { if (args.Parameters.Count < 1 || args.Parameters.Count > 2) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}buff [time(seconds)]", Specifier); + args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}buff [time in seconds]", Specifier); return; } int id = 0; int time = 60; + var timeLimit = (int.MaxValue / 60) - 1; if (!int.TryParse(args.Parameters[0], out id)) { var found = TShock.Utils.GetBuffByName(args.Parameters[0]); @@ -5985,10 +5986,11 @@ namespace TShockAPI int.TryParse(args.Parameters[1], out time); if (id > 0 && id < Main.maxBuffTypes) { - if (time < 0 || time > short.MaxValue) - time = 60; + // Max possible buff duration as of 1.4.2.2 is 35791393 seconds (415 days). + if (time < 0 || time > timeLimit) + time = timeLimit; args.Player.SetBuff(id, time * 60); - args.Player.SendSuccessMessage(string.Format("You have buffed yourself with {0}({1}) for {2} seconds!", + args.Player.SendSuccessMessage(string.Format("You have buffed yourself with {0} ({1}) for {2} seconds!", TShock.Utils.GetBuffName(id), TShock.Utils.GetBuffDescription(id), (time))); } else @@ -5999,11 +6001,12 @@ namespace TShockAPI { if (args.Parameters.Count < 2 || args.Parameters.Count > 3) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}gbuff [time(seconds)]", Specifier); + args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}gbuff [time in seconds]", Specifier); return; } int id = 0; int time = 60; + var timeLimit = (int.MaxValue / 60) - 1; var foundplr = TSPlayer.FindByNameOrID(args.Parameters[0]); if (foundplr.Count == 0) { @@ -6036,13 +6039,13 @@ namespace TShockAPI int.TryParse(args.Parameters[2], out time); if (id > 0 && id < Main.maxBuffTypes) { - if (time < 0 || time > short.MaxValue) - time = 60; + if (time < 0 || time > timeLimit) + time = timeLimit; foundplr[0].SetBuff(id, time * 60); - args.Player.SendSuccessMessage(string.Format("You have buffed {0} with {1}({2}) for {3} seconds!", + args.Player.SendSuccessMessage(string.Format("You have buffed {0} with {1} ({2}) for {3} seconds!", foundplr[0].Name, TShock.Utils.GetBuffName(id), TShock.Utils.GetBuffDescription(id), (time))); - foundplr[0].SendSuccessMessage(string.Format("{0} has buffed you with {1}({2}) for {3} seconds!", + foundplr[0].SendSuccessMessage(string.Format("{0} has buffed you with {1} ({2}) for {3} seconds!", args.Player.Name, TShock.Utils.GetBuffName(id), TShock.Utils.GetBuffDescription(id), (time))); }