Add method to get the registration date to the API (#1993)

* Add method to get the registration date to the API

* Removed unnecessary check

* Add method to get the registration IP to the API
This commit is contained in:
Drc-DEV 2020-01-24 23:09:28 +01:00 committed by Gabriele C
parent b85ba98d85
commit 8fb21c5fb4

View File

@ -132,6 +132,23 @@ public class AuthMeApi {
return null;
}
/**
* Get the registration ip address of a player.
*
* @param playerName The name of the player to process
* @return The registration ip address of the player
*/
public String getRegistrationIp(String playerName) {
PlayerAuth auth = playerCache.getAuth(playerName);
if (auth == null) {
auth = dataSource.getAuth(playerName);
}
if (auth != null) {
return auth.getRegistrationIp();
}
return null;
}
/**
* Get the last ip address of a player.
*
@ -196,6 +213,29 @@ public class AuthMeApi {
return null;
}
/**
* Get the registration (AuthMe) timestamp of a player.
*
* @param playerName The name of the player to process
*
* @return The timestamp of when the player was registered, or null if the player doesn't exist or is not registered
*/
public Instant getRegistrationTime(String playerName) {
Long registrationDate = getRegistrationMillis(playerName);
return registrationDate == null ? null : Instant.ofEpochMilli(registrationDate);
}
private Long getRegistrationMillis(String playerName) {
PlayerAuth auth = playerCache.getAuth(playerName);
if (auth == null) {
auth = dataSource.getAuth(playerName);
}
if (auth != null) {
return auth.getRegistrationDate();
}
return null;
}
/**
* Return whether the player is registered.
*