Fix KnownIps == 0 causing .Last() to fail (Fixes #1319 again).

Thanks to @Simon311 for being able to read. We love you. 💘

"You should laugh at yourself at least once every day."
This commit is contained in:
Lucas Nicodemus 2016-10-24 10:58:17 -06:00
parent 72ba9c2f77
commit 65fe410c31
No known key found for this signature in database
GPG key ID: CEE668CCE1BF2C7C
2 changed files with 15 additions and 8 deletions

View file

@ -409,16 +409,23 @@ namespace TShockAPI
KnownIps = JsonConvert.DeserializeObject<List<String>>(args.Player.User.KnownIps);
}
bool last = KnownIps.Last() == args.Player.IP;
if (!last)
if (KnownIps.Count == 0)
{
if (KnownIps.Count == 100)
{
KnownIps.RemoveAt(0);
}
KnownIps.Add(args.Player.IP);
}
else
{
bool last = KnownIps.Last() == args.Player.IP;
if (!last)
{
if (KnownIps.Count == 100)
{
KnownIps.RemoveAt(0);
}
KnownIps.Add(args.Player.IP);
}
}
args.Player.User.KnownIps = JsonConvert.SerializeObject(KnownIps, Formatting.Indented);
Users.UpdateLogin(args.Player.User);