#792 Add columns for registration IP and registration date
- Add columns for reg date and IP - Rename "ip" to "last IP"
This commit is contained in:
@@ -54,7 +54,7 @@ public class AccountsCommand implements ExecutableCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> accountList = dataSource.getAllAuthsByIp(auth.getIp());
|
||||
List<String> accountList = dataSource.getAllAuthsByIp(auth.getLastIp());
|
||||
if (accountList.isEmpty()) {
|
||||
commonService.send(sender, MessageKey.UNKNOWN_USER);
|
||||
} else if (accountList.size() == 1) {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import fr.xephi.authme.util.PlayerUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -13,18 +16,26 @@ public class GetIpCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
// Get the player query
|
||||
String playerName = arguments.get(0);
|
||||
|
||||
Player player = bukkitService.getPlayerExact(playerName);
|
||||
if (player == null) {
|
||||
sender.sendMessage("The player is not online");
|
||||
return;
|
||||
PlayerAuth auth = dataSource.getAuth(playerName);
|
||||
|
||||
if (player != null) {
|
||||
sender.sendMessage("Current IP of " + player.getName() + " is " + PlayerUtils.getPlayerIp(player)
|
||||
+ ":" + player.getAddress().getPort());
|
||||
}
|
||||
|
||||
sender.sendMessage(player.getName() + "'s IP is: " + player.getAddress().getAddress().getHostAddress()
|
||||
+ ":" + player.getAddress().getPort());
|
||||
if (auth == null) {
|
||||
String displayName = player == null ? playerName : player.getName();
|
||||
sender.sendMessage(displayName + " is not registered in the database");
|
||||
} else {
|
||||
sender.sendMessage("Database: last IP: " + auth.getLastIp() + ", registration IP: "
|
||||
+ auth.getRegistrationIp());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,6 @@ public class LastLoginCommand implements ExecutableCommand {
|
||||
// Show the player status
|
||||
sender.sendMessage("[AuthMe] " + playerName + " last login: " + date.toString());
|
||||
sender.sendMessage("[AuthMe] The player " + playerName + " last logged in " + lastLoginMessage + " ago.");
|
||||
sender.sendMessage("[AuthMe] Last Player's IP: " + auth.getIp());
|
||||
sender.sendMessage("[AuthMe] Last Player's IP: " + auth.getLastIp());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ public class RegisterAdminCommand implements ExecutableCommand {
|
||||
.name(playerNameLowerCase)
|
||||
.realName(playerName)
|
||||
.password(hashedPassword)
|
||||
.registrationDate(System.currentTimeMillis())
|
||||
.build();
|
||||
|
||||
if (!dataSource.saveAuth(auth)) {
|
||||
|
||||
@@ -77,8 +77,8 @@ class CountryLookup implements DebugSection {
|
||||
if (auth == null) {
|
||||
sender.sendMessage("No player with name '" + name + "'");
|
||||
} else {
|
||||
sender.sendMessage("Player '" + name + "' has IP address " + auth.getIp());
|
||||
outputInfoForIpAddr(sender, auth.getIp());
|
||||
sender.sendMessage("Player '" + name + "' has IP address " + auth.getLastIp());
|
||||
outputInfoForIpAddr(sender, auth.getLastIp());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-10
@@ -65,10 +65,12 @@ class PlayerAuthViewer implements DebugSection {
|
||||
*/
|
||||
private void displayAuthToSender(PlayerAuth auth, CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.GOLD + "[AuthMe] Player " + auth.getNickname() + " / " + auth.getRealName());
|
||||
sender.sendMessage("Email: " + auth.getEmail() + ". IP: " + auth.getIp() + ". Group: " + auth.getGroupId());
|
||||
sender.sendMessage("Email: " + auth.getEmail() + ". IP: " + auth.getLastIp() + ". Group: " + auth.getGroupId());
|
||||
sender.sendMessage("Quit location: "
|
||||
+ formatLocation(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld()));
|
||||
sender.sendMessage("Last login: " + formatLastLogin(auth));
|
||||
sender.sendMessage("Last login: " + formatDate(auth.getLastLogin()));
|
||||
sender.sendMessage("Registration: " + formatDate(auth.getRegistrationDate())
|
||||
+ " with IP " + auth.getRegistrationIp());
|
||||
|
||||
HashedPassword hashedPass = auth.getPassword();
|
||||
sender.sendMessage("Hash / salt (partial): '" + safeSubstring(hashedPass.getHash(), 6)
|
||||
@@ -94,17 +96,18 @@ class PlayerAuthViewer implements DebugSection {
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the last login date from the given PlayerAuth.
|
||||
* Formats the given timestamp to a human readable date.
|
||||
*
|
||||
* @param auth the auth object
|
||||
* @return the last login as human readable date
|
||||
* @param timestamp the timestamp to format (nullable)
|
||||
* @return the formatted timestamp
|
||||
*/
|
||||
private static String formatLastLogin(PlayerAuth auth) {
|
||||
long lastLogin = auth.getLastLogin();
|
||||
if (lastLogin == 0) {
|
||||
return "Never (0)";
|
||||
private static String formatDate(Long timestamp) {
|
||||
if (timestamp == null) {
|
||||
return "Not available (null)";
|
||||
} else if (timestamp == 0) {
|
||||
return "Not available (0)";
|
||||
} else {
|
||||
LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(lastLogin), ZoneId.systemDefault());
|
||||
LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
|
||||
return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(date);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user