diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java index c2da9b34a..64f54b205 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java @@ -83,7 +83,9 @@ public abstract class SQLDB extends Database { @Override public void run() { try { - clean(); + if (isOpen()) { + clean(); + } } catch (SQLException e) { Log.toLog(this.getClass().getName(), e); } finally { 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 c926ab004..04dfed32b 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 @@ -210,16 +210,18 @@ public class KillsTable extends UserIDTable { String[] gms = GMTimes.getGMKeyArray(); for (UUID serverUUID : allSessions.keySet()) { for (Map.Entry> entry : allSessions.get(serverUUID).entrySet()) { - UUID uuid = entry.getKey(); + UUID killer = entry.getKey(); List sessions = entry.getValue(); for (Session session : sessions) { int sessionID = session.getSessionID(); + System.out.println(usersTable.getSavedUUIDs()); for (PlayerKill kill : session.getPlayerKills()) { + System.out.println(kill); UUID victim = kill.getVictim(); long date = kill.getTime(); String weapon = kill.getWeapon(); - statement.setString(1, uuid.toString()); + statement.setString(1, killer.toString()); statement.setString(2, victim.toString()); statement.setInt(3, sessionID); statement.setLong(4, date); diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java index 34cc7eda3..5aece2ecc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java @@ -557,7 +557,7 @@ public class SessionsTable extends UserIDTable { String serverUUIDColumn = serverTable + "." + serverTable.getColumnUUID() + " as s_uuid"; statement = prepareStatement("SELECT " + - columnID + ", " + + tableName + "." + columnID + ", " + columnSessionStart + ", " + columnSessionEnd + ", " + columnDeaths + ", " + diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java index 0681952b4..70dccd3db 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java @@ -348,7 +348,7 @@ public class UsersTable extends UserIDTable { statement.setFetchSize(5000); set = statement.executeQuery(); Map users = new HashMap<>(); - if (set.next()) { + while (set.next()) { UUID uuid = UUID.fromString(set.getString(columnUUID)); String name = set.getString(columnName); long registered = set.getLong(columnRegistered); diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/move/BatchOperationTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/move/BatchOperationTable.java index 4b25673c4..ef2b1b9d1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/move/BatchOperationTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/move/BatchOperationTable.java @@ -6,6 +6,7 @@ package main.java.com.djrapitops.plan.database.tables.move; import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException; +import main.java.com.djrapitops.plan.data.UserInfo; import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.database.tables.ServerTable; @@ -15,6 +16,8 @@ import main.java.com.djrapitops.plan.systems.info.server.ServerInfo; import java.sql.SQLException; import java.util.List; +import java.util.Map; +import java.util.UUID; /** * A Fake table used to store a lot of big table operations. @@ -72,9 +75,7 @@ public class BatchOperationTable extends Table { toDB.removeAllData(); copyServers(toDB); - System.out.println(toDB.getDb().getServerTable().getBukkitServers().toString()); copyUsers(toDB); - System.out.println(toDB.getDb().getSavedUUIDs().toString()); copyWorlds(toDB); copyTPS(toDB); copyWebUsers(toDB); @@ -169,7 +170,8 @@ public class BatchOperationTable extends Table { Log.debug("Batch Copy Users"); UsersTable fromTable = db.getUsersTable(); UsersTable toTable = toDB.getDb().getUsersTable(); - toTable.insertUsers(fromTable.getUsers()); + Map users = fromTable.getUsers(); + toTable.insertUsers(users); toTable.updateKicked(fromTable.getAllTimesKicked()); } 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 abbaa1997..84b5c5cff 100644 --- a/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java @@ -224,11 +224,19 @@ public class DatabaseTest { } private void saveUserOne() throws SQLException { - db.getUsersTable().registerUser(uuid, 123456789L, "Test"); + saveUserOne(db); + } + + private void saveUserOne(Database database) throws SQLException { + database.getUsersTable().registerUser(uuid, 123456789L, "Test"); } private void saveUserTwo() throws SQLException { - db.getUsersTable().registerUser(uuid2, 123456789L, "Test"); + saveUserTwo(db); + } + + private void saveUserTwo(Database database) throws SQLException { + database.getUsersTable().registerUser(uuid2, 123456789L, "Test"); } @Test @@ -325,7 +333,11 @@ public class DatabaseTest { } private void saveTwoWorlds() throws SQLException { - db.getWorldTable().saveWorlds(worlds); + saveTwoWorlds(db); + } + + private void saveTwoWorlds(Database database) throws SQLException { + database.getWorldTable().saveWorlds(worlds); } private WorldTimes createWorldTimes() { @@ -606,10 +618,11 @@ public class DatabaseTest { TPSTable tpsTable = database.getTpsTable(); SecurityTable securityTable = database.getSecurityTable(); - saveUserTwo(); + saveUserOne(database); + saveUserTwo(database); userInfoTable.registerUserInfo(uuid, 223456789L); - saveTwoWorlds(); + saveTwoWorlds(database); Session session = new Session(12345L, "", ""); session.endSession(22345L);