use of com.djrapitops.plan.gathering.domain.ActiveSession in project Plan by plan-player-analytics.
the class ShutdownSaveTest method sessionsAreNotSavedWhenNotShuttingDown.
@Test
void sessionsAreNotSavedWhenNotShuttingDown() {
for (int i = 0; i < 100; i++) {
UUID playerUUID = UUID.randomUUID();
ActiveSession session = RandomData.randomUnfinishedSession(TestConstants.SERVER_UUID, new String[] { "w1", "w2" }, playerUUID);
sessionCache.cacheSession(playerUUID, session);
}
Optional<Future<?>> save = underTest.performSave();
assertFalse(save.isPresent());
List<FinishedSession> sessions = database.query(SessionQueries.fetchAllSessions());
assertEquals(0, sessions.size());
}
use of com.djrapitops.plan.gathering.domain.ActiveSession in project Plan by plan-player-analytics.
the class SessionCacheTest method setUp.
@BeforeEach
void setUp() {
session = new ActiveSession(uuid, serverUUID, 12345L, "World1", "SURVIVAL");
sessionCache = new SessionCache();
sessionCache.cacheSession(uuid, session);
}
use of com.djrapitops.plan.gathering.domain.ActiveSession in project Plan by plan-player-analytics.
the class SessionCacheTest method sessionsAreRemovedFromCacheOnStart.
@Test
void sessionsAreRemovedFromCacheOnStart() {
Optional<FinishedSession> ended = new SessionCache().cacheSession(uuid, new ActiveSession(uuid, serverUUID, 52345L, "World1", "SURVIVAL"));
assertTrue(ended.isPresent());
for (ActiveSession session : SessionCache.getActiveSessions()) {
if (session.getStart() == 12345L) {
fail("Session was still in cache: " + session);
}
}
}
use of com.djrapitops.plan.gathering.domain.ActiveSession in project Plan by plan-player-analytics.
the class BukkitAFKListenerTest method setUp.
@BeforeAll
static void setUp() {
PlanConfig config = Mockito.mock(PlanConfig.class);
when(config.get(TimeSettings.AFK_THRESHOLD)).thenReturn(TimeUnit.MINUTES.toMillis(3));
errorLogger = Mockito.mock(ErrorLogger.class);
underTest = new BukkitAFKListener(config, errorLogger);
new SessionCache().cacheSession(TestConstants.PLAYER_ONE_UUID, new ActiveSession(null, null, 0, null, null));
new SessionCache().cacheSession(TestConstants.PLAYER_TWO_UUID, new ActiveSession(null, null, 0, null, null));
}
use of com.djrapitops.plan.gathering.domain.ActiveSession in project Plan by plan-player-analytics.
the class WorldChangeListener method actOnEvent.
private void actOnEvent(ServerPlayerEntity player) {
long time = System.currentTimeMillis();
UUID uuid = player.getUuid();
String worldName = player.getServerWorld().getRegistryKey().getValue().toString();
String gameMode = player.interactionManager.getGameMode().name();
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
worldAliasSettings.addWorld(worldName);
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time));
}
Aggregations