Add timePlayed to playerDetails

This commit is contained in:
RedSparr0w 2020-02-26 12:34:36 +13:00
parent 7b0ae33151
commit 0403b685a9
4 changed files with 25 additions and 3 deletions

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

@ -87,6 +87,7 @@ public final class PlayerSQLManager {
details.setRights(Rights.forId((int) table.getColumn("rights").getValue()));
details.setDonatorType(DonatorType.forId((int) table.getColumn("donatorType").getValue()));
details.setLastLogin(System.currentTimeMillis());
details.setTimePlayed((long) table.getColumn("timePlayed").getValue());
return true;
}
@ -113,7 +114,7 @@ public final class PlayerSQLManager {
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.getDetails().getLastLogin()));
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()));