Fix Worlds not being saved when WorldTimes are saved.

This commit is contained in:
Rsl1122 2017-08-24 14:16:58 +03:00
parent bff67cd1e5
commit 23bc04c624
2 changed files with 7 additions and 3 deletions

View File

@ -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<String, GMTimes> worldTimesMap = worldTimes.getWorldTimes();
if (Verify.isEmpty(worldTimesMap)) {
return;
}
Set<String> 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<String, GMTimes> entry : worldTimes.getWorldTimes().entrySet()) {
for (Map.Entry<String, GMTimes> entry : worldTimesMap.entrySet()) {
String worldName = entry.getKey();
GMTimes gmTimes = entry.getValue();
statement.setString(1, uuid.toString());

View File

@ -352,7 +352,6 @@ public class DatabaseTest {
@Test
public void testSessionSaving() throws SQLException {
saveTwoWorlds();
saveUserOne();
saveUserTwo();