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:
parent
b85ba98d85
commit
8fb21c5fb4
@ -132,6 +132,23 @@ public class AuthMeApi {
|
|||||||
return null;
|
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.
|
* Get the last ip address of a player.
|
||||||
*
|
*
|
||||||
@ -196,6 +213,29 @@ public class AuthMeApi {
|
|||||||
return null;
|
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.
|
* Return whether the player is registered.
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user