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();
}
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);
}
Aggregations