#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:
ljacqu
2017-10-14 17:37:34 +02:00
parent 1487fc0d9e
commit 52d6476058
37 changed files with 362 additions and 235 deletions
@@ -62,6 +62,7 @@ public abstract class AbstractDataSourceConverter<S extends DataSource> implemen
} else {
adaptPlayerAuth(auth);
destination.saveAuth(auth);
destination.updateSession(auth);
destination.updateQuitLoc(auth);
}
}
@@ -18,6 +18,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
@@ -94,6 +95,7 @@ public class LoginSecurityConverter implements Converter {
} else {
PlayerAuth auth = buildAuthFromLoginSecurity(name, resultSet);
dataSource.saveAuth(auth);
dataSource.updateSession(auth);
++successfulSaves;
}
}
@@ -113,16 +115,17 @@ public class LoginSecurityConverter implements Converter {
* @return the created player auth object
*/
private static PlayerAuth buildAuthFromLoginSecurity(String name, ResultSet resultSet) throws SQLException {
// TODO #792: Last login should be null if not present
long lastLoginMillis = Optional.ofNullable(resultSet.getTimestamp("last_login"))
.map(Timestamp::getTime).orElse(System.currentTimeMillis());
Long lastLoginMillis = Optional.ofNullable(resultSet.getTimestamp("last_login"))
.map(Timestamp::getTime).orElse(null);
long regDate = Optional.ofNullable(resultSet.getDate("registration_date"))
.map(Date::getTime).orElse(System.currentTimeMillis());
return PlayerAuth.builder()
.name(name)
.realName(name)
.password(resultSet.getString("password"), null)
.ip(resultSet.getString("ip_address"))
.lastIp(resultSet.getString("ip_address"))
.lastLogin(lastLoginMillis)
// TODO #792: Register date
.registrationDate(regDate)
.locX(resultSet.getDouble("x"))
.locY(resultSet.getDouble("y"))
.locZ(resultSet.getDouble("z"))
@@ -80,11 +80,11 @@ public class RakamakConverter implements Converter {
PlayerAuth auth = PlayerAuth.builder()
.name(playerName)
.realName(playerName)
.ip(ip)
.lastIp(ip)
.password(psw)
.lastLogin(0)
.build();
database.saveAuth(auth);
database.updateSession(auth);
}
Utils.logAndSendMessage(sender, "Rakamak database has been imported correctly");
} catch (IOException ex) {
@@ -46,6 +46,7 @@ public class RoyalAuthConverter implements Converter {
.build();
dataSource.saveAuth(auth);
dataSource.updateSession(auth);
} catch (Exception e) {
ConsoleLogger.logException("Error while trying to import " + player.getName() + " RoyalAuth data", e);
}