From 2d5f9254ed65bc852ed523ca4c7fb4dd4b1ac513 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 14 Feb 2019 17:39:04 +0200 Subject: [PATCH] Made WorldTimesTable static information class: - Made WorldTimesTable constructor private - Removed getter in SQLDB --- .../java/com/djrapitops/plan/db/SQLDB.java | 7 ------ .../plan/db/patches/WorldsServerIDPatch.java | 18 ++++++-------- .../plan/db/sql/tables/WorldTimesTable.java | 24 ++++--------------- .../databases/sql/operation/SQLOps.java | 2 -- 4 files changed, 11 insertions(+), 40 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/SQLDB.java b/Plan/common/src/main/java/com/djrapitops/plan/db/SQLDB.java index 9955d1b05..0e2c8512a 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/db/SQLDB.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/db/SQLDB.java @@ -79,7 +79,6 @@ public abstract class SQLDB extends AbstractDatabase { private final KillsTable killsTable; private final SessionsTable sessionsTable; private final TPSTable tpsTable; - private final WorldTimesTable worldTimesTable; private final ServerTable serverTable; private final SettingsTable settingsTable; @@ -115,7 +114,6 @@ public abstract class SQLDB extends AbstractDatabase { userInfoTable = new UserInfoTable(this); sessionsTable = new SessionsTable(this); killsTable = new KillsTable(this); - worldTimesTable = new WorldTimesTable(this); settingsTable = new SettingsTable(this); fetchOps = new SQLFetchOps(this); @@ -360,11 +358,6 @@ public abstract class SQLDB extends AbstractDatabase { return tpsTable; } - @Deprecated - public WorldTimesTable getWorldTimesTable() { - return worldTimesTable; - } - @Deprecated public ServerTable getServerTable() { return serverTable; diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/patches/WorldsServerIDPatch.java b/Plan/common/src/main/java/com/djrapitops/plan/db/patches/WorldsServerIDPatch.java index fb182c1aa..0b0a35a33 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/db/patches/WorldsServerIDPatch.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/db/patches/WorldsServerIDPatch.java @@ -81,19 +81,16 @@ public class WorldsServerIDPatch extends Patch { } private Set getWorldNamesOld(UUID serverUUID) { - WorldTimesTable worldTimesTable = db.getWorldTimesTable(); - SessionsTable sessionsTable = db.getSessionsTable(); - - String worldIDColumn = worldTimesTable + "." + WorldTimesTable.WORLD_ID; - String worldSessionIDColumn = worldTimesTable + "." + WorldTimesTable.SESSION_ID; - String sessionIDColumn = sessionsTable + "." + SessionsTable.ID; - String sessionServerUUIDColumn = sessionsTable + "." + SessionsTable.SERVER_UUID; + String worldIDColumn = WorldTimesTable.TABLE_NAME + "." + WorldTimesTable.WORLD_ID; + String worldSessionIDColumn = WorldTimesTable.TABLE_NAME + "." + WorldTimesTable.SESSION_ID; + String sessionIDColumn = SessionsTable.TABLE_NAME + "." + SessionsTable.ID; + String sessionServerUUIDColumn = SessionsTable.TABLE_NAME + "." + SessionsTable.SERVER_UUID; String sql = "SELECT DISTINCT " + WorldTable.NAME + " FROM " + WorldTable.TABLE_NAME + - " INNER JOIN " + worldTimesTable + " on " + worldIDColumn + "=" + WorldTable.TABLE_NAME + "." + WorldTable.ID + - " INNER JOIN " + sessionsTable + " on " + worldSessionIDColumn + "=" + sessionIDColumn + + " INNER JOIN " + WorldTimesTable.TABLE_NAME + " on " + worldIDColumn + "=" + WorldTable.TABLE_NAME + "." + WorldTable.ID + + " INNER JOIN " + SessionsTable.TABLE_NAME + " on " + worldSessionIDColumn + "=" + sessionIDColumn + " WHERE " + sessionServerUUIDColumn + "=?"; return query(new QueryStatement>(sql, 1000) { @@ -126,8 +123,7 @@ public class WorldsServerIDPatch extends Patch { .collect(Collectors.toList() ))); - WorldTimesTable worldTimesTable = db.getWorldTimesTable(); - String sql = "UPDATE " + worldTimesTable + " SET " + + String sql = "UPDATE " + WorldTimesTable.TABLE_NAME + " SET " + WorldTimesTable.WORLD_ID + "=?" + " WHERE " + WorldTimesTable.WORLD_ID + "=?" + " AND " + "server_id=?"; diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/WorldTimesTable.java b/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/WorldTimesTable.java index 5c905333e..3422d4524 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/WorldTimesTable.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/WorldTimesTable.java @@ -20,7 +20,6 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.store.keys.SessionKeys; import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.db.DBType; -import com.djrapitops.plan.db.SQLDB; import com.djrapitops.plan.db.patches.Version10Patch; import com.djrapitops.plan.db.patches.WorldTimesOptimizationPatch; import com.djrapitops.plan.db.patches.WorldTimesSeverIDPatch; @@ -31,13 +30,10 @@ import com.djrapitops.plan.db.sql.parsing.Sql; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.Map; -import java.util.Objects; import java.util.UUID; /** - * Table that is in charge of storing playtime data for each world in each GameMode. - *

- * Table Name: plan_world_times + * Information about database table 'plan_world_times'. *

* Patches related to this table: * {@link Version10Patch} @@ -47,7 +43,7 @@ import java.util.UUID; * * @author Rsl1122 */ -public class WorldTimesTable extends Table { +public class WorldTimesTable { public static final String TABLE_NAME = "plan_world_times"; @@ -75,8 +71,8 @@ public class WorldTimesTable extends Table { WorldTable.SELECT_WORLD_ID_STATEMENT + ", " + "?, ?, ?, ?, ?, ?)"; - public WorldTimesTable(SQLDB db) { - super(TABLE_NAME, db); + private WorldTimesTable() { + /* Static information class */ } public static String createTableSQL(DBType dbType) { @@ -122,16 +118,4 @@ public class WorldTimesTable extends Table { statement.addBatch(); } } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof WorldTimesTable)) return false; - return super.equals(o); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode()); - } } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java b/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java index cf74d0792..f2a6ff76d 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java @@ -29,7 +29,6 @@ public class SQLOps { protected final KillsTable killsTable; protected final SessionsTable sessionsTable; protected final TPSTable tpsTable; - protected final WorldTimesTable worldTimesTable; protected final ServerTable serverTable; protected final SettingsTable settingsTable; @@ -41,7 +40,6 @@ public class SQLOps { killsTable = db.getKillsTable(); sessionsTable = db.getSessionsTable(); tpsTable = db.getTpsTable(); - worldTimesTable = db.getWorldTimesTable(); serverTable = db.getServerTable(); settingsTable = db.getSettingsTable(); }