diff --git a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java index e5ce3942d..c6e9bd54e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java @@ -107,7 +107,7 @@ public class PlayerProfile implements OfflinePlayer { UUID maxServer = null; for (Map.Entry entry : getWorldTimesPerServer().entrySet()) { long playTime = entry.getValue().getTotal(); - if (playTime < max) { + if (playTime > max) { max = playTime; maxServer = entry.getKey(); } @@ -499,4 +499,23 @@ public class PlayerProfile implements OfflinePlayer { public void setOp(boolean b) { /* Do nothing */ } + + public void calculateWorldTimesPerServer() { + if (worldTimesMap.containsKey(MiscUtils.getIPlan().getServerUuid())) { + return; + } + + for (Map.Entry> entry : sessions.entrySet()) { + UUID serverUUID = entry.getKey(); + List sessions = entry.getValue(); + + WorldTimes times = worldTimesMap.getOrDefault(serverUUID, new WorldTimes(new HashMap<>())); + for (Session session : sessions) { + WorldTimes worldTimes = session.getWorldTimes(); + times.add(worldTimes); + } + worldTimesMap.put(serverUUID, times); + } + + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/data/time/WorldTimes.java b/Plan/src/main/java/com/djrapitops/plan/data/time/WorldTimes.java index 3e51d66f0..1d4144494 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/time/WorldTimes.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/time/WorldTimes.java @@ -158,4 +158,18 @@ public class WorldTimes { public String getCurrentWorld() { return currentWorld; } + + public void add(WorldTimes toAdd) { + Map times = toAdd.getWorldTimes(); + for (Map.Entry entry : times.entrySet()) { + String worldName = entry.getKey(); + GMTimes gmTimes = entry.getValue(); + + GMTimes currentGMTimes = getGMTimes(worldName); + for (String gm : GMTimes.getGMKeyArray()) { + currentGMTimes.addTime(gm, gmTimes.getTime(gm)); + } + worldTimes.put(worldName, currentGMTimes); + } + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java index 25484d43c..bb3ff5188 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java @@ -257,6 +257,7 @@ public abstract class SQLDB extends Database { Map> sessions = sessionsTable.getSessions(uuid); profile.setSessions(sessions); + profile.calculateWorldTimesPerServer(); profile.setTotalWorldTimes(worldTimesTable.getWorldTimesOfUser(uuid)); return profile;