Merge pull request #2300 from moisterrific/patch-21
Change max buff limit from short to int
This commit is contained in:
commit
544ba45f50
1 changed files with 14 additions and 11 deletions
|
|
@ -531,7 +531,7 @@ namespace TShockAPI
|
||||||
add(new Command(Permissions.buff, Buff, "buff")
|
add(new Command(Permissions.buff, Buff, "buff")
|
||||||
{
|
{
|
||||||
AllowServer = false,
|
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")
|
add(new Command(Permissions.clear, Clear, "clear")
|
||||||
{
|
{
|
||||||
|
|
@ -539,7 +539,7 @@ namespace TShockAPI
|
||||||
});
|
});
|
||||||
add(new Command(Permissions.buffplayer, GBuff, "gbuff", "buffplayer")
|
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")
|
add(new Command(Permissions.godmode, ToggleGodMode, "godmode")
|
||||||
{
|
{
|
||||||
|
|
@ -5961,11 +5961,12 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (args.Parameters.Count < 1 || args.Parameters.Count > 2)
|
if (args.Parameters.Count < 1 || args.Parameters.Count > 2)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}buff <buff id/name> [time(seconds)]", Specifier);
|
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}buff <buff name or ID> [time in seconds]", Specifier);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int id = 0;
|
int id = 0;
|
||||||
int time = 60;
|
int time = 60;
|
||||||
|
var timeLimit = (int.MaxValue / 60) - 1;
|
||||||
if (!int.TryParse(args.Parameters[0], out id))
|
if (!int.TryParse(args.Parameters[0], out id))
|
||||||
{
|
{
|
||||||
var found = TShock.Utils.GetBuffByName(args.Parameters[0]);
|
var found = TShock.Utils.GetBuffByName(args.Parameters[0]);
|
||||||
|
|
@ -5985,10 +5986,11 @@ namespace TShockAPI
|
||||||
int.TryParse(args.Parameters[1], out time);
|
int.TryParse(args.Parameters[1], out time);
|
||||||
if (id > 0 && id < Main.maxBuffTypes)
|
if (id > 0 && id < Main.maxBuffTypes)
|
||||||
{
|
{
|
||||||
if (time < 0 || time > short.MaxValue)
|
// Max possible buff duration as of 1.4.2.2 is 35791393 seconds (415 days).
|
||||||
time = 60;
|
if (time < 0 || time > timeLimit)
|
||||||
|
time = timeLimit;
|
||||||
args.Player.SetBuff(id, time * 60);
|
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)));
|
TShock.Utils.GetBuffName(id), TShock.Utils.GetBuffDescription(id), (time)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -5999,11 +6001,12 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (args.Parameters.Count < 2 || args.Parameters.Count > 3)
|
if (args.Parameters.Count < 2 || args.Parameters.Count > 3)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}gbuff <player> <buff id/name> [time(seconds)]", Specifier);
|
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}gbuff <player> <buff name or ID> [time in seconds]", Specifier);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int id = 0;
|
int id = 0;
|
||||||
int time = 60;
|
int time = 60;
|
||||||
|
var timeLimit = (int.MaxValue / 60) - 1;
|
||||||
var foundplr = TSPlayer.FindByNameOrID(args.Parameters[0]);
|
var foundplr = TSPlayer.FindByNameOrID(args.Parameters[0]);
|
||||||
if (foundplr.Count == 0)
|
if (foundplr.Count == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -6036,13 +6039,13 @@ namespace TShockAPI
|
||||||
int.TryParse(args.Parameters[2], out time);
|
int.TryParse(args.Parameters[2], out time);
|
||||||
if (id > 0 && id < Main.maxBuffTypes)
|
if (id > 0 && id < Main.maxBuffTypes)
|
||||||
{
|
{
|
||||||
if (time < 0 || time > short.MaxValue)
|
if (time < 0 || time > timeLimit)
|
||||||
time = 60;
|
time = timeLimit;
|
||||||
foundplr[0].SetBuff(id, time * 60);
|
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),
|
foundplr[0].Name, TShock.Utils.GetBuffName(id),
|
||||||
TShock.Utils.GetBuffDescription(id), (time)));
|
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),
|
args.Player.Name, TShock.Utils.GetBuffName(id),
|
||||||
TShock.Utils.GetBuffDescription(id), (time)));
|
TShock.Utils.GetBuffDescription(id), (time)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue