diff --git a/Plan/src/main/java/com/djrapitops/plan/data/UserInfo.java b/Plan/src/main/java/com/djrapitops/plan/data/UserInfo.java index 5a1c349bc..3751fd2f2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/UserInfo.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/UserInfo.java @@ -86,4 +86,16 @@ public class UserInfo { public int hashCode() { return Objects.hash(uuid, name, registered, lastSeen, banned, opped); } + + @Override + public String toString() { + return "UserInfo{" + + "uuid=" + uuid + + ", name='" + name + '\'' + + ", registered=" + registered + + ", lastSeen=" + lastSeen + + ", banned=" + banned + + ", opped=" + opped + + '}'; + } } \ No newline at end of file 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 8766629db..3540c936c 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 @@ -85,7 +85,7 @@ public abstract class SQLDB extends Database { } catch (SQLException e) { Log.toLog(this.getClass().getName(), e); } finally { - cancel(); + super.cancel(); } } }).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * secondsDelay); diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/Table.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/Table.java index 68af7cbaf..2f92e76b6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/Table.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/Table.java @@ -114,6 +114,7 @@ public abstract class Table { * @throws SQLException */ protected PreparedStatement prepareStatement(String sql) throws SQLException { + System.out.println(sql); return getConnection().prepareStatement(sql); } @@ -210,4 +211,8 @@ public abstract class Table { public int hashCode() { return Objects.hashCode(tableName, db, usingMySQL); } + + public SQLDB getDb() { + return db; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java index 4e0c2904a..04f438049 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java @@ -226,8 +226,9 @@ public class UserInfoTable extends UserIDTable { userInfos.add(new UserInfo(uuid, "", registered, op, banned)); - serverMap.put(uuid, userInfos); + serverMap.put(serverUUID, userInfos); } + System.out.println(serverMap); return serverMap; } finally { endTransaction(statement); 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 e7b4d04d5..ac43a7552 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 @@ -4,6 +4,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.database.Database; import main.java.com.djrapitops.plan.database.databases.SQLDB; @@ -67,92 +68,105 @@ public class BatchOperationTable extends Table { if (toDB.equals(this)) { return; } - toDB.db.removeAllData(); + Log.debug("Start Batch Copy Everything"); + toDB.getDb().removeAllData(); copyServers(toDB); + System.out.println(toDB.getDb().getServerTable().getServerNames().toString()); copyUsers(toDB); + System.out.println(toDB.getDb().getSavedUUIDs().toString()); copyWorlds(toDB); - copyUserInfo(toDB); - copyActions(toDB); - copyCommandUse(toDB); - copyIPsAndGeolocs(toDB); - copyNicknames(toDB); copyTPS(toDB); copyWebUsers(toDB); + copyCommandUse(toDB); + copyActions(toDB); + copyIPsAndGeolocs(toDB); + copyNicknames(toDB); copySessions(toDB); + copyUserInfo(toDB); } public void copyActions(BatchOperationTable toDB) throws SQLException { if (toDB.equals(this)) { return; } - toDB.db.getActionsTable().insertActions(db.getActionsTable().getAllActions()); + Log.debug("Batch Copy Actions"); + toDB.getDb().getActionsTable().insertActions(db.getActionsTable().getAllActions()); } public void copyCommandUse(BatchOperationTable toDB) throws SQLException { if (toDB.equals(this)) { return; } - toDB.db.getCommandUseTable().insertCommandUsage(db.getCommandUseTable().getAllCommandUsages()); + Log.debug("Batch Copy Commands"); + toDB.getDb().getCommandUseTable().insertCommandUsage(db.getCommandUseTable().getAllCommandUsages()); } public void copyIPsAndGeolocs(BatchOperationTable toDB) throws SQLException { if (toDB.equals(this)) { return; } - toDB.db.getIpsTable().insertIPsAndGeolocations(db.getIpsTable().getAllIPsAndGeolocations()); + Log.debug("Batch Copy IPs & Geolocations"); + toDB.getDb().getIpsTable().insertIPsAndGeolocations(db.getIpsTable().getAllIPsAndGeolocations()); } public void copyNicknames(BatchOperationTable toDB) throws SQLException { if (toDB.equals(this)) { return; } - toDB.db.getNicknamesTable().insertNicknames(db.getNicknamesTable().getAllNicknames()); + Log.debug("Batch Copy Nicknames"); + toDB.getDb().getNicknamesTable().insertNicknames(db.getNicknamesTable().getAllNicknames()); } public void copyWebUsers(BatchOperationTable toDB) throws SQLException { if (toDB.equals(this)) { return; } - toDB.db.getSecurityTable().addUsers(db.getSecurityTable().getUsers()); + Log.debug("Batch Copy WebUsers"); + toDB.getDb().getSecurityTable().addUsers(db.getSecurityTable().getUsers()); } public void copyServers(BatchOperationTable toDB) throws SQLException { if (toDB.equals(this)) { return; } + Log.debug("Batch Copy Servers"); ServerTable serverTable = db.getServerTable(); List servers = serverTable.getBukkitServers(); serverTable.getBungeeInfo().ifPresent(servers::add); - toDB.db.getServerTable().insertAllServers(servers); + toDB.getDb().getServerTable().insertAllServers(servers); } public void copyTPS(BatchOperationTable toDB) throws SQLException { if (toDB.equals(this)) { return; } - toDB.db.getTpsTable().insertAllTPS(db.getTpsTable().getAllTPS()); + Log.debug("Batch Copy TPS"); + toDB.getDb().getTpsTable().insertAllTPS(db.getTpsTable().getAllTPS()); } public void copyUserInfo(BatchOperationTable toDB) throws SQLException { if (toDB.equals(this)) { return; } - toDB.db.getUserInfoTable().insertUserInfo(db.getUserInfoTable().getAllUserInfo()); + Log.debug("Batch Copy UserInfo"); + toDB.getDb().getUserInfoTable().insertUserInfo(db.getUserInfoTable().getAllUserInfo()); } public void copyWorlds(BatchOperationTable toDB) throws SQLException { if (toDB.equals(this)) { return; } - toDB.db.getWorldTable().saveWorlds(db.getWorldTable().getWorlds()); + Log.debug("Batch Copy Worlds"); + toDB.getDb().getWorldTable().saveWorlds(db.getWorldTable().getWorlds()); } public void copyUsers(BatchOperationTable toDB) throws SQLException { if (toDB.equals(this)) { return; } + Log.debug("Batch Copy Users"); UsersTable fromTable = db.getUsersTable(); - UsersTable toTable = toDB.db.getUsersTable(); + UsersTable toTable = toDB.getDb().getUsersTable(); toTable.insertUsers(fromTable.getUsers()); toTable.updateKicked(fromTable.getAllTimesKicked()); } @@ -161,6 +175,7 @@ public class BatchOperationTable extends Table { if (toDB.equals(this)) { return; } - toDB.db.getSessionsTable().insertSessions(db.getSessionsTable().getAllSessions(true), true); + Log.debug("Batch Copy Sessions"); + toDB.getDb().getSessionsTable().insertSessions(db.getSessionsTable().getAllSessions(true), true); } } \ No newline at end of file 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 0da11d704..abbaa1997 100644 --- a/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java @@ -596,6 +596,7 @@ public class DatabaseTest { } private void saveAllData(Database database) throws SQLException { + System.out.println("Saving all possible data to the Database.."); UserInfoTable userInfoTable = database.getUserInfoTable(); UsersTable usersTable = database.getUsersTable(); SessionsTable sessionsTable = database.getSessionsTable(); @@ -647,6 +648,7 @@ public class DatabaseTest { } securityTable.addNewUser(new WebUser("Test", "RandomGarbageBlah", 0)); + System.out.println("Done!\n"); } @Test