Fixed player online indicator on Bungee/Velocity

This commit is contained in:
Rsl1122 2019-09-26 10:25:15 +03:00
parent 0c92fbbaa2
commit 7f2ad68014

View File

@ -71,11 +71,12 @@ public class SessionCache {
* @return Optional: previous session. Recipients of this object should decide if it needs to be saved. * @return Optional: previous session. Recipients of this object should decide if it needs to be saved.
*/ */
public Optional<Session> cacheSession(UUID playerUUID, Session session) { public Optional<Session> cacheSession(UUID playerUUID, Session session) {
Optional<Session> inProgress = Optional.empty();
if (getCachedSession(playerUUID).isPresent()) { if (getCachedSession(playerUUID).isPresent()) {
return endSession(playerUUID, session.getUnsafe(SessionKeys.START)); inProgress = endSession(playerUUID, session.getUnsafe(SessionKeys.START));
} }
ACTIVE_SESSIONS.put(playerUUID, session); 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) { if (session == null || session.getUnsafe(SessionKeys.START) > time) {
return Optional.empty(); return Optional.empty();
} }
removeSessionFromCache(playerUUID); ACTIVE_SESSIONS.remove(playerUUID);
session.endSession(time); session.endSession(time);
return Optional.of(session); return Optional.of(session);
} }
protected void removeSessionFromCache(UUID playerUUID) {
ACTIVE_SESSIONS.remove(playerUUID);
}
} }