diff --git a/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java index d05202c..80f3a09 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java @@ -88,6 +88,17 @@ public class SteamwarUser { return bedrock; } + public double getOnlineTime() { + ResultSet set = SQL.select("SELECT SUM(UNIX_TIMESTAMP(EndTime) - UNIX_TIMESTAMP(StartTime)) as Playtime FROM Session WHERE UserID = ?", id); + try { + set.next(); + return set.getBigDecimal("Playtime").doubleValue(); + } catch (SQLException throwables) { + throwables.printStackTrace(); + } + return 0; + } + private static SteamwarUser fromDB(String statement, Object identifier){ ResultSet rs = SQL.select(statement, identifier); try {