diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/patches/WorldsOptimizationPatch.java b/Plan/common/src/main/java/com/djrapitops/plan/db/patches/WorldsOptimizationPatch.java index 0606f0a70..48e101770 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/db/patches/WorldsOptimizationPatch.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/db/patches/WorldsOptimizationPatch.java @@ -19,7 +19,6 @@ package com.djrapitops.plan.db.patches; import com.djrapitops.plan.api.exceptions.database.DBOpException; import com.djrapitops.plan.db.SQLDB; import com.djrapitops.plan.db.sql.tables.WorldTable; -import com.djrapitops.plan.db.sql.tables.WorldTable.Col; public class WorldsOptimizationPatch extends Patch { @@ -34,8 +33,8 @@ public class WorldsOptimizationPatch extends Patch { @Override public boolean hasBeenApplied() { - return hasColumn(tableName, Col.ID.get()) - && hasColumn(tableName, Col.SERVER_UUID.get()) + return hasColumn(tableName, WorldTable.ID) + && hasColumn(tableName, WorldTable.SERVER_UUID) && !hasColumn(tableName, "server_id") && !hasTable(tempTableName); // If this table exists the patch has failed to finish. } @@ -50,13 +49,13 @@ public class WorldsOptimizationPatch extends Patch { db.getWorldTable().createTable(); execute("INSERT INTO " + tableName + " (" + - Col.ID + ", " + - Col.SERVER_UUID + ", " + - Col.NAME + + WorldTable.ID + ", " + + WorldTable.SERVER_UUID + ", " + + WorldTable.NAME + ") SELECT " + - Col.ID + ", " + + WorldTable.ID + ", " + "(SELECT plan_servers.uuid FROM plan_servers WHERE plan_servers.id = " + tempTableName + ".server_id LIMIT 1), " + - Col.NAME + + WorldTable.NAME + " FROM " + tempTableName ); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/WorldTable.java b/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/WorldTable.java index 74c38f7d2..b75e07e57 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/WorldTable.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/WorldTable.java @@ -24,7 +24,6 @@ import com.djrapitops.plan.db.access.QueryStatement; import com.djrapitops.plan.db.patches.Version10Patch; import com.djrapitops.plan.db.patches.WorldsOptimizationPatch; import com.djrapitops.plan.db.patches.WorldsServerIDPatch; -import com.djrapitops.plan.db.sql.parsing.Column; import com.djrapitops.plan.db.sql.parsing.CreateTableParser; import com.djrapitops.plan.db.sql.parsing.Sql; import com.djrapitops.plugin.utilities.Verify; @@ -44,7 +43,7 @@ import java.util.*; * {@link WorldsServerIDPatch} * {@link WorldsOptimizationPatch} * - * @author Rsl1122 / Database version 7 + * @author Rsl1122 */ public class WorldTable extends Table { @@ -60,9 +59,9 @@ public class WorldTable extends Table { public WorldTable(SQLDB db) { super(TABLE_NAME, db); serverTable = db.getServerTable(); - statementSelectID = "(SELECT " + Col.ID + " FROM " + tableName + - " WHERE (" + Col.NAME + "=?)" + - " AND (" + Col.SERVER_UUID + "=?)" + + statementSelectID = "(SELECT " + ID + " FROM " + tableName + + " WHERE (" + NAME + "=?)" + + " AND (" + SERVER_UUID + "=?)" + " LIMIT 1)"; } @@ -85,7 +84,7 @@ public class WorldTable extends Table { public List getWorlds(UUID serverUUID) { String sql = "SELECT * FROM " + tableName + - " WHERE " + Col.SERVER_UUID + "=?"; + " WHERE " + SERVER_UUID + "=?"; return query(new QueryStatement>(sql) { @@ -98,7 +97,7 @@ public class WorldTable extends Table { public List processResults(ResultSet set) throws SQLException { List worldNames = new ArrayList<>(); while (set.next()) { - String worldName = set.getString(Col.NAME.get()); + String worldName = set.getString(NAME); worldNames.add(worldName); } return worldNames; @@ -108,8 +107,8 @@ public class WorldTable extends Table { public void saveWorlds(Map> worldMap) { String sql = "INSERT INTO " + tableName + " (" - + Col.NAME + ", " - + Col.SERVER_UUID + + NAME + ", " + + SERVER_UUID + ") VALUES (?, ?)"; executeBatch(new ExecStatement(sql) { @@ -149,8 +148,8 @@ public class WorldTable extends Table { } String sql = "INSERT INTO " + tableName + " (" - + Col.NAME + ", " - + Col.SERVER_UUID + + NAME + ", " + + SERVER_UUID + ") VALUES (?, ?)"; executeBatch(new ExecStatement(sql) { @@ -166,8 +165,8 @@ public class WorldTable extends Table { } public Set getWorldNames(UUID serverUUID) { - String sql = "SELECT DISTINCT " + Col.NAME + " FROM " + tableName + - " WHERE " + Col.SERVER_UUID + "=?"; + String sql = "SELECT DISTINCT " + NAME + " FROM " + tableName + + " WHERE " + SERVER_UUID + "=?"; return query(new QueryStatement>(sql, 100) { @Override public void prepare(PreparedStatement statement) throws SQLException { @@ -178,36 +177,13 @@ public class WorldTable extends Table { public Set processResults(ResultSet set) throws SQLException { Set worldNames = new HashSet<>(); while (set.next()) { - worldNames.add(set.getString(Col.NAME.get())); + worldNames.add(set.getString(NAME)); } return worldNames; } }); } - @Deprecated - public enum Col implements Column { - @Deprecated ID("id"), - @Deprecated SERVER_UUID("server_uuid"), - @Deprecated NAME("world_name"); - - private final String column; - - Col(String column) { - this.column = column; - } - - @Override - public String get() { - return toString(); - } - - @Override - public String toString() { - return column; - } - } - @Override public boolean equals(Object o) { if (this == o) return true; 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 e4158e612..03b8886d3 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 @@ -114,8 +114,8 @@ public class WorldTimesTable extends Table { } public void addWorldTimesToSessions(UUID uuid, Map sessions) { - String worldIDColumn = worldTable + "." + WorldTable.Col.ID; - String worldNameColumn = worldTable + "." + WorldTable.Col.NAME + " as world_name"; + String worldIDColumn = worldTable + "." + WorldTable.ID; + String worldNameColumn = worldTable + "." + WorldTable.NAME + " as world_name"; String sql = "SELECT " + Col.SESSION_ID + ", " + Col.SURVIVAL + ", " + @@ -195,8 +195,8 @@ public class WorldTimesTable extends Table { } public WorldTimes getWorldTimesOfServer(UUID serverUUID) { - String worldIDColumn = worldTable + "." + WorldTable.Col.ID; - String worldNameColumn = worldTable + "." + WorldTable.Col.NAME + " as world"; + String worldIDColumn = worldTable + "." + WorldTable.ID; + String worldNameColumn = worldTable + "." + WorldTable.NAME + " as world"; String sql = "SELECT " + "SUM(" + Col.SURVIVAL + ") as survival, " + "SUM(" + Col.CREATIVE + ") as creative, " + @@ -237,8 +237,8 @@ public class WorldTimesTable extends Table { } public WorldTimes getWorldTimesOfUser(UUID uuid) { - String worldIDColumn = worldTable + "." + WorldTable.Col.ID; - String worldNameColumn = worldTable + "." + WorldTable.Col.NAME + " as world"; + String worldIDColumn = worldTable + "." + WorldTable.ID; + String worldNameColumn = worldTable + "." + WorldTable.NAME + " as world"; String sql = "SELECT " + "SUM(" + Col.SURVIVAL + ") as survival, " + "SUM(" + Col.CREATIVE + ") as creative, " + @@ -279,8 +279,8 @@ public class WorldTimesTable extends Table { } public Map getAllWorldTimesBySessionID() { - String worldIDColumn = worldTable + "." + WorldTable.Col.ID; - String worldNameColumn = worldTable + "." + WorldTable.Col.NAME + " as world"; + String worldIDColumn = worldTable + "." + WorldTable.ID; + String worldNameColumn = worldTable + "." + WorldTable.NAME + " as world"; String sql = "SELECT " + Col.SESSION_ID + ", " + Col.SURVIVAL + ", " +