From 23bc04c624773714c90f3610571d4bccd07f68f1 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 24 Aug 2017 14:16:58 +0300 Subject: [PATCH] Fix Worlds not being saved when WorldTimes are saved. --- .../djrapitops/plan/database/tables/WorldTimesTable.java | 9 +++++++-- .../java/com/djrapitops/plan/database/DatabaseTest.java | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTimesTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTimesTable.java index ccb1bc9d1..13c67a17a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTimesTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTimesTable.java @@ -13,6 +13,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.Map; +import java.util.Set; import java.util.UUID; /** @@ -63,10 +64,14 @@ public class WorldTimesTable extends UserIDTable { } public void saveWorldTimes(UUID uuid, long sessionID, WorldTimes worldTimes) throws SQLException { - if (Verify.isEmpty(worldTimes.getWorldTimes())) { + Map worldTimesMap = worldTimes.getWorldTimes(); + if (Verify.isEmpty(worldTimesMap)) { return; } + Set worldNames = worldTimesMap.keySet(); + db.getWorldTable().saveWorlds(worldNames); + PreparedStatement statement = null; try { statement = prepareStatement("INSERT INTO " + tableName + " (" + @@ -82,7 +87,7 @@ public class WorldTimesTable extends UserIDTable { worldTable.statementSelectID + ", " + "?, ?, ?, ?, ?)"); - for (Map.Entry entry : worldTimes.getWorldTimes().entrySet()) { + for (Map.Entry entry : worldTimesMap.entrySet()) { String worldName = entry.getKey(); GMTimes gmTimes = entry.getValue(); statement.setString(1, uuid.toString()); diff --git a/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java b/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java index 4a090380f..4cbbbe995 100644 --- a/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java +++ b/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java @@ -352,7 +352,6 @@ public class DatabaseTest { @Test public void testSessionSaving() throws SQLException { - saveTwoWorlds(); saveUserOne(); saveUserTwo();