Fixed WorldTimes not being saved for sessions for known worlds.

This commit is contained in:
Rsl1122 2017-09-08 19:27:03 +03:00
parent e14e7aeda7
commit 7ee67d4be7

View File

@ -9,9 +9,7 @@ import main.java.com.djrapitops.plan.database.sql.TableSqlParser;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.List;
/** /**
* Table class representing database table plan_worlds. * Table class representing database table plan_worlds.
@ -83,9 +81,10 @@ public class WorldTable extends Table {
*/ */
public void saveWorlds(Collection<String> worlds) throws SQLException { public void saveWorlds(Collection<String> worlds) throws SQLException {
Verify.nullCheck(worlds); Verify.nullCheck(worlds);
Set<String> worldsToSave = new HashSet<>(worlds);
List<String> saved = getWorlds(); List<String> saved = getWorlds();
worlds.removeAll(saved); worldsToSave.removeAll(saved);
if (Verify.isEmpty(worlds)) { if (Verify.isEmpty(worlds)) {
return; return;
} }
@ -95,7 +94,7 @@ public class WorldTable extends Table {
statement = prepareStatement("INSERT INTO " + tableName + " (" statement = prepareStatement("INSERT INTO " + tableName + " ("
+ columnWorldName + columnWorldName
+ ") VALUES (?)"); + ") VALUES (?)");
for (String world : worlds) { for (String world : worldsToSave) {
statement.setString(1, world); statement.setString(1, world);
statement.addBatch(); statement.addBatch();
} }