diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java index 3c2bd99ac..8f77dac16 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java @@ -493,4 +493,24 @@ public class SessionsTable extends UserIDTable { close(set, statement); } } + + public long getLastSeen(UUID uuid) throws SQLException { + PreparedStatement statement = null; + ResultSet set = null; + try { + statement = prepareStatement("SELECT" + + " MAX(" + columnSessionEnd + ") as last_seen" + + " FROM " + tableName + + " WHERE " + columnUserID + "=" + usersTable.statementSelectID); + statement.setString(1, uuid.toString()); + set = statement.executeQuery(); + if (set.next()) { + return set.getLong("last_seen"); + } + return 0; + } finally { + endTransaction(statement); + close(set, statement); + } + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java index e4348dfca..bf326ee34 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java @@ -53,9 +53,12 @@ public class InspectPageParser { } public String parse() throws SQLException, FileNotFoundException { + // TODO Player is online parts Log.debug("Database", "Inspect Parse Fetch"); Benchmark.start("Inspect Parse, Fetch"); Database db = plugin.getDB(); + SessionsTable sessionsTable = db.getSessionsTable(); + UserInfo userInfo = db.getUserInfoTable().getUserInfo(uuid); int timesKicked = db.getUsersTable().getTimesKicked(uuid); @@ -64,11 +67,14 @@ public class InspectPageParser { addValue("playerName", userInfo.getName()); addValue("registered", FormatUtils.formatTimeStampYear(userInfo.getRegistered())); - long lastSeen = userInfo.getLastSeen(); - addValue("lastSeen", FormatUtils.formatTimeStampYear(lastSeen)); + long lastSeen = sessionsTable.getLastSeen(uuid); + if (lastSeen != 0) { + addValue("lastSeen", FormatUtils.formatTimeStampYear(lastSeen)); + } else { + addValue("lastSeen", "-"); + } addValue("kickCount", timesKicked); - SessionsTable sessionsTable = db.getSessionsTable(); Map playtimeByServer = sessionsTable.getPlaytimeByServer(uuid); List geolocations = db.getIpsTable().getGeolocations(uuid);