From 9418e4304f3f2c035b2827eb5caa8710a83cfb1c Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Wed, 12 May 2021 13:47:27 -0400 Subject: [PATCH 1/8] Change max buff limit from short to int --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 601c2591..5b27ebd7 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5985,7 +5985,7 @@ namespace TShockAPI int.TryParse(args.Parameters[1], out time); if (id > 0 && id < Main.maxBuffTypes) { - if (time < 0 || time > short.MaxValue) + if (time < 0 || time > int.MaxValue) time = 60; args.Player.SetBuff(id, time * 60); args.Player.SendSuccessMessage(string.Format("You have buffed yourself with {0}({1}) for {2} seconds!", From 0d686ea80f5737212da409a085c065a0120d19d1 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Wed, 12 May 2021 15:39:11 -0400 Subject: [PATCH 2/8] Change duration to actual max value in seconds --- TShockAPI/Commands.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 5b27ebd7..5c356d04 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5985,8 +5985,9 @@ namespace TShockAPI int.TryParse(args.Parameters[1], out time); if (id > 0 && id < Main.maxBuffTypes) { - if (time < 0 || time > int.MaxValue) - time = 60; + // Max possible buff duration as of 1.4.2.2 is 35791393 seconds (415 days). + if (time < 0 || time > 35791393) + time = 35791393; args.Player.SetBuff(id, time * 60); args.Player.SendSuccessMessage(string.Format("You have buffed yourself with {0}({1}) for {2} seconds!", TShock.Utils.GetBuffName(id), TShock.Utils.GetBuffDescription(id), (time))); From 0eadfaba52d30f2e23958ff4a9339c0071c41901 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Wed, 12 May 2021 15:48:38 -0400 Subject: [PATCH 3/8] Minor fixes --- TShockAPI/Commands.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 5c356d04..66fce497 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5961,11 +5961,11 @@ 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; + int time = 35791393; if (!int.TryParse(args.Parameters[0], out id)) { var found = TShock.Utils.GetBuffByName(args.Parameters[0]); @@ -5989,7 +5989,7 @@ namespace TShockAPI if (time < 0 || time > 35791393) time = 35791393; 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 From 68c650f4fa05a93b92e361067d7665f83b6bb07f Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Wed, 12 May 2021 21:36:26 -0400 Subject: [PATCH 4/8] More minor fixes Reverted default (when no duration is specified) buff duration to 60s, added formula instead of hard coding max duration as per Quake's recommendation, made error message more self-explanatory --- TShockAPI/Commands.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 66fce497..b03ad31e 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -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 in seconds]", Specifier); + args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}buff [optional: time in seconds]", Specifier); return; } int id = 0; - int time = 35791393; + 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]); @@ -5986,8 +5987,8 @@ namespace TShockAPI if (id > 0 && id < Main.maxBuffTypes) { // Max possible buff duration as of 1.4.2.2 is 35791393 seconds (415 days). - if (time < 0 || time > 35791393) - time = 35791393; + 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!", TShock.Utils.GetBuffName(id), TShock.Utils.GetBuffDescription(id), (time))); From dacc20e9c3657346fba0ef63c9f32048e4e654c5 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Wed, 12 May 2021 21:40:44 -0400 Subject: [PATCH 5/8] Update buff command HelpText More properly explain the command functionality --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index b03ad31e..e66b77ac 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") { From 306e4d1ab4497a62fc17f8d940324531c3bffc78 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Wed, 12 May 2021 21:45:06 -0400 Subject: [PATCH 6/8] fix typo sigh --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index e66b77ac..51d57c7f 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5966,7 +5966,7 @@ namespace TShockAPI } int id = 0; int time = 60; - var timeLimit = (int.MaxValue / 60) - 1 + var timeLimit = (int.MaxValue / 60) - 1; if (!int.TryParse(args.Parameters[0], out id)) { var found = TShock.Utils.GetBuffByName(args.Parameters[0]); From d2a0a539f49ce519ed7633382317dcce516f7fc6 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Wed, 12 May 2021 22:08:10 -0400 Subject: [PATCH 7/8] fix error msg --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 51d57c7f..b89afe3d 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5961,7 +5961,7 @@ namespace TShockAPI { if (args.Parameters.Count < 1 || args.Parameters.Count > 2) { - args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}buff [optional: time in seconds]", Specifier); + args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}buff [time in seconds]", Specifier); return; } int id = 0; From a1ddea4f597bbf62bb7124f9b5c47050a65ef6b9 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Fri, 14 May 2021 13:44:37 -0400 Subject: [PATCH 8/8] Update /gbuff with the same changes totally forgot this existed --- TShockAPI/Commands.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index b89afe3d..bf2db430 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -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") { @@ -6001,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) { @@ -6038,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))); }