mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-08 17:37:34 +01:00
Added ACTIVE_SESSION to Player placeholders
Playtime was not being updated live for the player placeholders because the Active session was not added in the PlayerContainer before calculations. - Added the active session (if present) to the placeholders - Updated session state when it is fetched from the cache (world time) Affects issues: - Close #1209
This commit is contained in:
parent
97094a9e03
commit
f641c44bf2
@ -23,6 +23,7 @@ import com.djrapitops.plan.delivery.domain.mutators.PlayerVersusMutator;
|
|||||||
import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator;
|
import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator;
|
||||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||||
|
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||||
import com.djrapitops.plan.identification.ServerInfo;
|
import com.djrapitops.plan.identification.ServerInfo;
|
||||||
import com.djrapitops.plan.storage.database.DBSystem;
|
import com.djrapitops.plan.storage.database.DBSystem;
|
||||||
import com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries;
|
import com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries;
|
||||||
@ -161,6 +162,8 @@ public class PlayerPlaceHolder extends AbstractPlanPlaceHolder {
|
|||||||
// Checkstyle.ON: CyclomaticComplexity
|
// Checkstyle.ON: CyclomaticComplexity
|
||||||
|
|
||||||
private PlayerContainer getPlayer(UUID playerUUID) {
|
private PlayerContainer getPlayer(UUID playerUUID) {
|
||||||
return dbSystem.getDatabase().query(ContainerFetchQueries.fetchPlayerContainer(playerUUID));
|
PlayerContainer player = dbSystem.getDatabase().query(ContainerFetchQueries.fetchPlayerContainer(playerUUID));
|
||||||
|
SessionCache.getCachedSession(playerUUID).ifPresent(session -> player.putRawData(PlayerKeys.ACTIVE_SESSION, session));
|
||||||
|
return player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,7 @@ public class SessionCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void refreshActiveSessionsState() {
|
public static void refreshActiveSessionsState() {
|
||||||
for (Session session : ACTIVE_SESSIONS.values()) {
|
ACTIVE_SESSIONS.values().forEach(Session::updateState);
|
||||||
session.getValue(SessionKeys.WORLD_TIMES).ifPresent(worldTimes -> worldTimes.updateState(System.currentTimeMillis()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +59,9 @@ public class SessionCache {
|
|||||||
* @return Optional with the session inside it if found.
|
* @return Optional with the session inside it if found.
|
||||||
*/
|
*/
|
||||||
public static Optional<Session> getCachedSession(UUID playerUUID) {
|
public static Optional<Session> getCachedSession(UUID playerUUID) {
|
||||||
return Optional.ofNullable(ACTIVE_SESSIONS.get(playerUUID));
|
Optional<Session> found = Optional.ofNullable(ACTIVE_SESSIONS.get(playerUUID));
|
||||||
|
found.ifPresent(Session::updateState);
|
||||||
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,4 +254,8 @@ public class Session extends DynamicDataContainer implements DateHolder {
|
|||||||
", afkTime=" + afkTime +
|
", afkTime=" + afkTime +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateState() {
|
||||||
|
worldTimes.updateState(System.currentTimeMillis());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user