Merge pull request #112 from RedSparr0w/master

Fixup lastLogin in database
This commit is contained in:
Daniel Ginovker 2020-02-26 11:20:43 -05:00 committed by GitHub
commit 8086e878dc
6 changed files with 31 additions and 7 deletions

View file

@ -191,10 +191,11 @@ public final class PlayerSession {
}
PreparedStatement statement;
try {
statement = connection.prepareStatement("UPDATE members SET online = ? AND lastWorld = ? WHERE username = ?");
statement = connection.prepareStatement("UPDATE members SET online = ?, lastWorld = ?, lastLogin = ? WHERE username = ?");
statement.setBoolean(1, true);
statement.setInt(2, worldId);
statement.setString(3, username);
statement.setLong(3, System.currentTimeMillis());
statement.setString(4, username);
statement.execute();
SQLManager.close(connection);
} catch (SQLException e) {

View file

@ -50,11 +50,16 @@ public class PlayerDetails {
* The unique id of the account.
*/
private int uid;
/**
* The account's last game login.
*/
private long lastLogin = -1;
/**
* The account's last game login.
*/
private long timePlayed = 0;
/**
* The time the player is muted for.
@ -370,7 +375,7 @@ public class PlayerDetails {
public void setIcon(Icon icon) {
this.icon = icon;
}
/**
* Gets the lastLogin.
* @return the lastLogin.
@ -386,6 +391,22 @@ public class PlayerDetails {
public void setLastLogin(long lastLogin) {
this.lastLogin = lastLogin;
}
/**
* Gets the timePlayed.
* @return the timePlayed.
*/
public long getTimePlayed() {
return timePlayed;
}
/**
* Sets the timePlayed.
* @param timePlayed the timePlayed to set
*/
public void setTimePlayed(long timePlayed) {
this.timePlayed = timePlayed;
}
/**
* Sets the mute time.

View file

@ -86,7 +86,8 @@ public final class PlayerSQLManager {
details.getShop().parsePerks((String) table.getColumn("perks").getValue());
details.setRights(Rights.forId((int) table.getColumn("rights").getValue()));
details.setDonatorType(DonatorType.forId((int) table.getColumn("donatorType").getValue()));
details.setLastLogin((long) table.getColumn("lastLogin").getValue());
details.setLastLogin(System.currentTimeMillis());
details.setTimePlayed((long) table.getColumn("timePlayed").getValue());
return true;
}
@ -106,14 +107,15 @@ public final class PlayerSQLManager {
details.getCommunication().save(table);
}
table.getColumn("bank").updateValue(player.getBank().format());
table.getColumn("lastLogin").updateValue(System.currentTimeMillis());
table.getColumn("lastLogin").updateValue(player.getDetails().getLastLogin());
table.getColumn("ge").updateValue(player.getGrandExchange().format());
table.getColumn("inventory").updateValue(player.getInventory().format());
table.getColumn("equipment").updateValue(player.getEquipment().format());
table.getColumn("netWorth").updateValue(player.getMonitor().getNetworth());
table.getColumn("lastGameIp").updateValue(player.getDetails().getIpAddress());
table.getColumn("ironManMode").updateValue(player.getIronmanManager().getMode().name());
table.getColumn("timePlayed").updateValue((long) table.getColumn("timePlayed").getValue() + (System.currentTimeMillis() - player.getAttribute("startTime", System.currentTimeMillis()))); table.getColumn("ip").updateValue(getAddressLog((String) table.getColumn("ip").getValue(), details.getInfo().getIp()));
table.getColumn("timePlayed").updateValue(player.getDetails().getTimePlayed() + (System.currentTimeMillis() - player.getDetails().getLastLogin()));
table.getColumn("ip").updateValue(getAddressLog((String) table.getColumn("ip").getValue(), details.getInfo().getIp()));
table.getColumn("mac").updateValue(getAddressLog((String) table.getColumn("mac").getValue(), details.getInfo().getMac()));
table.getColumn("serial").updateValue(getAddressLog((String) table.getColumn("serial").getValue(), details.getInfo().getSerial()));
table.getColumn("computerName").updateValue(getAddressLog((String) table.getColumn("computerName").getValue(), details.getInfo().getCompName()));