diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/KillsTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/KillsTable.java index 407966b12..23e30811e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/KillsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/KillsTable.java @@ -156,17 +156,18 @@ public class KillsTable extends UserIDTable { PreparedStatement statement = null; ResultSet set = null; try { - String usersIDColumn = usersTable + "." + usersTable.getColumnID(); - String usersUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as victim_uuid"; - String usersUUIDColumn2 = usersTable + "." + usersTable.getColumnUUID() + " as killer_uuid"; + String usersVictimIDColumn = usersTable + "." + usersTable.getColumnID(); + String usersKillerIDColumn = "a." + usersTable.getColumnID(); + String usersVictimUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as victim_uuid"; + String usersKillerUUIDColumn = "a." + usersTable.getColumnUUID() + " as killer_uuid"; statement = prepareStatement("SELECT " + columnDate + ", " + columnWeapon + ", " + - usersUUIDColumn + ", " + - usersUUIDColumn2 + + usersVictimUUIDColumn + ", " + + usersKillerUUIDColumn + " FROM " + tableName + - " JOIN " + usersTable + " on " + usersIDColumn + "=" + columnVictimUserID + - " JOIN " + usersTable + " on " + usersIDColumn + "=" + columnKillerUserID); + " JOIN " + usersTable + " on " + usersVictimIDColumn + "=" + columnVictimUserID + + " JOIN " + usersTable + " a on " + usersKillerIDColumn + "=" + columnKillerUserID); statement.setFetchSize(10000); set = statement.executeQuery(); diff --git a/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java b/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java index 59bd904c2..e7d781660 100644 --- a/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java @@ -704,4 +704,23 @@ public class DatabaseTest { assertFalse(sSessions.isEmpty()); assertEquals(session, sSessions.get(0)); } + + @Test + public void testKillTableGetKillsOfServer() throws SQLException, DatabaseInitException { + saveUserOne(); + saveUserTwo(); + + KillsTable killsTable = db.getKillsTable(); + List expected = createKills(); + killsTable.savePlayerKills(uuid, 1, expected); + + commitTest(); + + Map> playerKills = killsTable.getPlayerKills(); + List kills = playerKills.get(uuid); + assertFalse(playerKills.isEmpty()); + assertNotNull(kills); + assertFalse(kills.isEmpty()); + assertEquals(expected, kills); + } }