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:
parent
72ba9c2f77
commit
65fe410c31
2 changed files with 15 additions and 8 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue