Fix ArrayIndexOutOfBounds when a newly added admin leaves the game

This commit is contained in:
Allink 2023-07-25 01:50:46 +01:00
parent ac704614c0
commit 08c8393abc
No known key found for this signature in database
2 changed files with 16 additions and 2 deletions

View File

@ -66,8 +66,13 @@ public class ActivityLogEntry implements IConfig
public void addLogin()
{
Date currentTime = Date.from(Instant.now());
timestamps.add("Login: " + FUtil.dateToString(currentTime));
this.addLogin(System.currentTimeMillis());
}
public void addLogin(final long timestamp)
{
Date time = Date.from(Instant.ofEpochMilli(timestamp));
timestamps.add("Login: " + FUtil.dateToString(time));
}
public void addLogout()

View File

@ -194,6 +194,15 @@ public class AdminList extends FreedomService
// Save admin
plugin.sql.addAdmin(admin);
// Add login time
UUID uuid = admin.getUuid();
Player player = Bukkit.getPlayer(uuid);
if (player != null)
{
plugin.acl.getActivityLog(player).addLogin(player.getLastLogin());
}
return true;
}