mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-30 16:19:56 +08:00
Attempt to preserve causal relation of join and quit events
Affects issues: - Possibly fixed #2578
This commit is contained in:
parent
8d2b4acb41
commit
9d7684e3fb
@ -90,10 +90,13 @@ public class SessionCache {
|
||||
* @return Optional: ended session. Recipients of this object should decide if it needs to be saved.
|
||||
*/
|
||||
public Optional<FinishedSession> endSession(UUID playerUUID, long time, ActiveSession activeSession) {
|
||||
if (activeSession == null || activeSession.getStart() > time) {
|
||||
if (activeSession == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
ACTIVE_SESSIONS.remove(playerUUID);
|
||||
if (activeSession.getStart() > time) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(activeSession.toFinishedSession(time));
|
||||
}
|
||||
|
||||
|
@ -80,12 +80,13 @@ public class PlayerJoinEventConsumer {
|
||||
}
|
||||
|
||||
public void onJoinGameServer(PlayerJoin join) {
|
||||
Optional<FinishedSession> interruptedSession = cacheActiveSession(join);
|
||||
processing.submitCritical(() -> {
|
||||
storeWorldInformation(join);
|
||||
storeGamePlayer(join)
|
||||
.thenRunAsync(() -> {
|
||||
storeJoinAddress(join);
|
||||
cacheActiveSession(join).ifPresent(this::storeInterruptedSession);
|
||||
interruptedSession.ifPresent(this::storeInterruptedSession);
|
||||
storeGeolocation(join);
|
||||
storeOperatorStatus(join);
|
||||
storeNickname(join);
|
||||
@ -96,9 +97,9 @@ public class PlayerJoinEventConsumer {
|
||||
}
|
||||
|
||||
public void onJoinProxyServer(PlayerJoin join) {
|
||||
cacheActiveSession(join);
|
||||
processing.submitCritical(() -> storeProxyPlayer(join)
|
||||
.thenRunAsync(() -> {
|
||||
cacheActiveSession(join);
|
||||
storeGeolocation(join);
|
||||
updatePlayerDataExtensionValues(join);
|
||||
updateExport(join);
|
||||
|
@ -22,6 +22,7 @@ import com.djrapitops.plan.extension.ExtensionSvc;
|
||||
import com.djrapitops.plan.gathering.cache.JoinAddressCache;
|
||||
import com.djrapitops.plan.gathering.cache.NicknameCache;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import com.djrapitops.plan.gathering.domain.event.PlayerLeave;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
@ -67,6 +68,13 @@ public class PlayerLeaveEventConsumer {
|
||||
}
|
||||
|
||||
public void onLeaveGameServer(PlayerLeave leave) {
|
||||
Optional<ActiveSession> activeSession = SessionCache.getCachedSession(leave.getPlayerUUID());
|
||||
if (activeSession.isEmpty()) {
|
||||
// Quit event processed before Join event, delay processing
|
||||
processing.submitCritical(() -> onLeaveGameServer(leave));
|
||||
return;
|
||||
}
|
||||
|
||||
endSession(leave).ifPresent(this::storeFinishedSession);
|
||||
storeBanStatus(leave);
|
||||
updateExport(leave);
|
||||
|
Loading…
Reference in New Issue
Block a user