Search in sources :

Example 6 with PlayerKill

use of com.djrapitops.plan.gathering.domain.PlayerKill in project Plan by plan-player-analytics.

the class KillQueries method extractKillFromResults.

private static Optional<PlayerKill> extractKillFromResults(ResultSet set) throws SQLException {
    String victimName = set.getString("victim_name");
    String killerName = set.getString("killer_name");
    if (victimName != null && killerName != null) {
        UUID killer = UUID.fromString(set.getString(KillsTable.KILLER_UUID));
        UUID victim = UUID.fromString(set.getString(KillsTable.VICTIM_UUID));
        long date = set.getLong(KillsTable.DATE);
        String weapon = set.getString(KillsTable.WEAPON);
        return Optional.of(new PlayerKill(new PlayerKill.Killer(killer, killerName), new PlayerKill.Victim(victim, victimName), new ServerIdentifier(ServerUUID.fromString(set.getString(KillsTable.SERVER_UUID)), Server.getIdentifiableName(set.getString("server_name"), set.getInt("server_id"))), weapon, date));
    }
    return Optional.empty();
}
Also used : ServerIdentifier(com.djrapitops.plan.delivery.domain.ServerIdentifier) PlayerKill(com.djrapitops.plan.gathering.domain.PlayerKill) ServerUUID(com.djrapitops.plan.identification.ServerUUID) UUID(java.util.UUID)

Example 7 with PlayerKill

use of com.djrapitops.plan.gathering.domain.PlayerKill in project Plan by plan-player-analytics.

the class SessionQueriesTest method testKillTableGetKillsOfServer.

@Test
default void testKillTableGetKillsOfServer() {
    prepareForSessionSave();
    FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
    List<PlayerKill> expected = session.getExtraData(PlayerKills.class).map(PlayerKills::asList).get();
    execute(DataStoreQueries.storeSession(session));
    forcePersistenceCheck();
    Map<ServerUUID, List<FinishedSession>> sessions = db().query(SessionQueries.fetchSessionsOfPlayer(playerUUID));
    List<FinishedSession> savedSessions = sessions.get(serverUUID());
    assertNotNull(savedSessions);
    assertFalse(savedSessions.isEmpty());
    List<PlayerKill> got = savedSessions.get(0).getExtraData(PlayerKills.class).map(PlayerKills::asList).get();
    assertEquals(expected, got);
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) PlayerKill(com.djrapitops.plan.gathering.domain.PlayerKill) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Aggregations

PlayerKill (com.djrapitops.plan.gathering.domain.PlayerKill)7 ServerUUID (com.djrapitops.plan.identification.ServerUUID)4 UUID (java.util.UUID)3 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)2 Test (org.junit.jupiter.api.Test)2 Nickname (com.djrapitops.plan.delivery.domain.Nickname)1 ServerIdentifier (com.djrapitops.plan.delivery.domain.ServerIdentifier)1 PlayerContainer (com.djrapitops.plan.delivery.domain.container.PlayerContainer)1 WorldPie (com.djrapitops.plan.delivery.rendering.json.graphs.pie.WorldPie)1 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)1 GMTimes (com.djrapitops.plan.gathering.domain.GMTimes)1 PlayerKills (com.djrapitops.plan.gathering.domain.PlayerKills)1 WorldTimes (com.djrapitops.plan.gathering.domain.WorldTimes)1 Database (com.djrapitops.plan.storage.database.Database)1 PlayerContainerQuery (com.djrapitops.plan.storage.database.queries.containers.PlayerContainerQuery)1 DateHolderRecentComparator (com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator)1 RepeatedTest (org.junit.jupiter.api.RepeatedTest)1