diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java b/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java index 4b0ce2ce0..4a6fb62c4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java @@ -154,11 +154,11 @@ public class Session extends DataContainer implements DateHolder { } public void setWorldTimes(WorldTimes worldTimes) { - putRawData(SessionKeys.WORLD_TIMES, worldTimes); + this.worldTimes = worldTimes; } public void setPlayerKills(List playerKills) { - putRawData(SessionKeys.PLAYER_KILLS, playerKills); + this.playerKills = playerKills; } public boolean isFetchedFromDB() { @@ -231,7 +231,6 @@ public class Session extends DataContainer implements DateHolder { } Map playtimePerAlias = worldTimes.getPlaytimePerAlias(); - long total = worldTimes.getTotal(); long longest = 0; String theWorld = "-"; @@ -244,6 +243,11 @@ public class Session extends DataContainer implements DateHolder { } } + long total = worldTimes.getTotal(); + // Prevent arithmetic error if 0 + if (total <= 0) { + total = -1; + } double quotient = longest * 1.0 / total; return theWorld + " (" + Formatters.percentage().apply(quotient) + ")"; 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 1554528bb..24ec27938 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 @@ -170,8 +170,11 @@ public class WorldTimes { } public Map getPlaytimePerAlias() { - Map playtimePerWorld = getWorldTimes() // WorldTimes Map - .entrySet().stream() + if (times.isEmpty()) { + return new HashMap<>(); + } + + Map playtimePerWorld = times.entrySet().stream() // WorldTimes Map .collect(Collectors.toMap( Map.Entry::getKey, entry -> entry.getValue().getTotal() // GMTimes.getTotal