#1460 Fix null handling in recent players command

- Last login might be null
This commit is contained in:
ljacqu
2018-01-06 20:26:07 +01:00
parent ea87075cd2
commit a29738e2a8
2 changed files with 32 additions and 3 deletions
@@ -42,8 +42,13 @@ public class RecentPlayersCommand implements ExecutableCommand {
}
private String formatPlayerMessage(PlayerAuth auth) {
LocalDateTime lastLogin = LocalDateTime.ofInstant(ofEpochMilli(auth.getLastLogin()), getZoneId());
String lastLoginText = DATE_FORMAT.format(lastLogin);
String lastLoginText;
if (auth.getLastLogin() == null) {
lastLoginText = "never";
} else {
LocalDateTime lastLogin = LocalDateTime.ofInstant(ofEpochMilli(auth.getLastLogin()), getZoneId());
lastLoginText = DATE_FORMAT.format(lastLogin);
}
return "- " + auth.getRealName() + " (" + lastLoginText + " with IP " + auth.getLastIp() + ")";
}