diff --git a/Plan/common/src/main/java/com/djrapitops/plan/gathering/cache/SessionCache.java b/Plan/common/src/main/java/com/djrapitops/plan/gathering/cache/SessionCache.java index 5558339e5..822b3fea8 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/gathering/cache/SessionCache.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/gathering/cache/SessionCache.java @@ -71,11 +71,12 @@ public class SessionCache { * @return Optional: previous session. Recipients of this object should decide if it needs to be saved. */ public Optional cacheSession(UUID playerUUID, Session session) { + Optional inProgress = Optional.empty(); if (getCachedSession(playerUUID).isPresent()) { - return endSession(playerUUID, session.getUnsafe(SessionKeys.START)); + inProgress = endSession(playerUUID, session.getUnsafe(SessionKeys.START)); } ACTIVE_SESSIONS.put(playerUUID, session); - return Optional.empty(); + return inProgress; } /** @@ -90,12 +91,8 @@ public class SessionCache { if (session == null || session.getUnsafe(SessionKeys.START) > time) { return Optional.empty(); } - removeSessionFromCache(playerUUID); + ACTIVE_SESSIONS.remove(playerUUID); session.endSession(time); return Optional.of(session); } - - protected void removeSessionFromCache(UUID playerUUID) { - ACTIVE_SESSIONS.remove(playerUUID); - } }