mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-05 10:20:23 +01:00
Removed Locations table
This commit is contained in:
parent
4411e18708
commit
e3333fabb8
@ -72,8 +72,7 @@ public abstract class RawData {
|
||||
* @param value Any value the placeholder should be replaced with.
|
||||
*/
|
||||
public void addValue(String placeholder, Serializable value) {
|
||||
placeholder = addPlaceholderSigns(placeholder);
|
||||
replaceMap.put(placeholder, value.toString());
|
||||
replaceMap.put(addPlaceholderSigns(placeholder), value.toString());
|
||||
}
|
||||
|
||||
private String addPlaceholderSigns(String placeholder) {
|
||||
|
@ -38,14 +38,6 @@ public abstract class Database {
|
||||
*/
|
||||
protected KillsTable killsTable;
|
||||
|
||||
/**
|
||||
* Table representing plan_locations in the database.
|
||||
*
|
||||
* @deprecated Removed in 3.5.2
|
||||
*/
|
||||
@Deprecated
|
||||
protected LocationsTable locationsTable;
|
||||
|
||||
/**
|
||||
* Table representing plan_nicknames in the database.
|
||||
*/
|
||||
@ -315,17 +307,6 @@ public abstract class Database {
|
||||
return killsTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the locations table.
|
||||
*
|
||||
* @return Table representing plan_locations
|
||||
* @deprecated Removed in 3.5.2
|
||||
*/
|
||||
@Deprecated
|
||||
public LocationsTable getLocationsTable() {
|
||||
return locationsTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the ips table.
|
||||
*
|
||||
|
@ -48,7 +48,6 @@ public abstract class SQLDB extends Database {
|
||||
gmTimesTable = new GMTimesTable(this, usingMySQL);
|
||||
sessionsTable = new SessionsTable(this, usingMySQL);
|
||||
killsTable = new KillsTable(this, usingMySQL);
|
||||
locationsTable = new LocationsTable(this, usingMySQL);
|
||||
ipsTable = new IPsTable(this, usingMySQL);
|
||||
nicknamesTable = new NicknamesTable(this, usingMySQL);
|
||||
commandUseTable = new CommandUseTable(this, usingMySQL);
|
||||
@ -132,13 +131,8 @@ public abstract class SQLDB extends Database {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean newDatabase = true;
|
||||
try {
|
||||
getVersion();
|
||||
newDatabase = false;
|
||||
} catch (Exception ignored) {
|
||||
boolean newDatabase = isNewDatabase();
|
||||
|
||||
}
|
||||
if (!versionTable.createTable()) {
|
||||
Log.error("Failed to create table: " + versionTable.getTableName());
|
||||
return false;
|
||||
@ -149,28 +143,46 @@ public abstract class SQLDB extends Database {
|
||||
setVersion(8);
|
||||
}
|
||||
|
||||
Benchmark.start("DCreate tables");
|
||||
|
||||
for (Table table : getAllTables()) {
|
||||
if (!table.createTable()) {
|
||||
Log.error("Failed to create table: " + table.getTableName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!securityTable.createTable()) {
|
||||
Log.error("Failed to create table: " + securityTable.getTableName());
|
||||
if (!createTables()) {
|
||||
return false;
|
||||
}
|
||||
Benchmark.stop("Database", "Create tables");
|
||||
|
||||
if (!newDatabase && getVersion() < 8) {
|
||||
setVersion(8);
|
||||
}
|
||||
connection.prepareStatement("DROP TABLE IF EXISTS plan_locations").execute();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tables that contain data.
|
||||
*
|
||||
* Updates table columns to latest schema.
|
||||
*
|
||||
* @return true if successful.
|
||||
*/
|
||||
private boolean createTables() {
|
||||
Benchmark.start("Create tables");
|
||||
for (Table table : getAllTables()) {
|
||||
if (!table.createTable()) {
|
||||
Log.error("Failed to create table: " + table.getTableName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Benchmark.stop("Database", "Create tables");
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isNewDatabase() {
|
||||
try {
|
||||
getVersion();
|
||||
return false;
|
||||
} catch (Exception ignored) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -214,7 +226,7 @@ public abstract class SQLDB extends Database {
|
||||
usersTable, gmTimesTable, ipsTable,
|
||||
nicknamesTable, sessionsTable, killsTable,
|
||||
commandUseTable, tpsTable, worldTable,
|
||||
worldTimesTable};
|
||||
worldTimesTable, securityTable};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -222,7 +234,7 @@ public abstract class SQLDB extends Database {
|
||||
*/
|
||||
public Table[] getAllTablesInRemoveOrder() {
|
||||
return new Table[]{
|
||||
locationsTable, gmTimesTable, ipsTable,
|
||||
gmTimesTable, ipsTable,
|
||||
nicknamesTable, sessionsTable, killsTable,
|
||||
worldTimesTable, worldTable, usersTable,
|
||||
commandUseTable, tpsTable};
|
||||
@ -305,7 +317,6 @@ public abstract class SQLDB extends Database {
|
||||
}
|
||||
int userId = usersTable.getUserId(uuid);
|
||||
boolean success = userId != -1
|
||||
&& locationsTable.removeUserLocations(userId)
|
||||
&& ipsTable.removeUserIPs(userId)
|
||||
&& nicknamesTable.removeUserNicknames(userId)
|
||||
&& gmTimesTable.removeUserGMTimes(userId)
|
||||
@ -567,7 +578,6 @@ public abstract class SQLDB extends Database {
|
||||
try {
|
||||
checkConnection();
|
||||
tpsTable.clean();
|
||||
locationsTable.removeAllData();
|
||||
Log.info("Clean complete.");
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
|
@ -1,89 +0,0 @@
|
||||
package main.java.com.djrapitops.plan.database.tables;
|
||||
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class LocationsTable extends Table {
|
||||
|
||||
private final String columnUserID;
|
||||
private final String columnID;
|
||||
private final String columnCoordinatesX;
|
||||
private final String columnCoordinatesZ;
|
||||
private final String columnWorld;
|
||||
|
||||
/**
|
||||
* @param db
|
||||
* @param usingMySQL
|
||||
* @deprecated Deprecated because it isn't used anymore
|
||||
*/
|
||||
@Deprecated
|
||||
public LocationsTable(SQLDB db, boolean usingMySQL) {
|
||||
super("plan_locations", db, usingMySQL);
|
||||
columnID = "id";
|
||||
columnUserID = "user_id";
|
||||
columnCoordinatesX = "x";
|
||||
columnCoordinatesZ = "z";
|
||||
columnWorld = "world_name";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean removeAllData() {
|
||||
try {
|
||||
execute("DELETE FROM " + tableName);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean createTable() {
|
||||
UsersTable usersTable = db.getUsersTable();
|
||||
try {
|
||||
execute("CREATE TABLE IF NOT EXISTS " + tableName + " ("
|
||||
+ columnID + " integer " + ((usingMySQL) ? "NOT NULL AUTO_INCREMENT" : "PRIMARY KEY") + ", "
|
||||
+ columnUserID + " integer NOT NULL, "
|
||||
+ columnCoordinatesX + " integer NOT NULL, "
|
||||
+ columnCoordinatesZ + " integer NOT NULL, "
|
||||
+ columnWorld + " varchar(64) NOT NULL, "
|
||||
+ (usingMySQL ? "PRIMARY KEY (" + usersTable.getColumnID() + "), " : "")
|
||||
+ "FOREIGN KEY(" + columnUserID + ") REFERENCES " + usersTable.getTableName() + "(" + usersTable.getColumnID() + ")"
|
||||
+ ")"
|
||||
);
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
Log.toLog(this.getClass().getName(), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean removeUserLocations(int userId) {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
statement = prepareStatement("DELETE FROM " + tableName + " WHERE (" + columnUserID + "=?)");
|
||||
statement.setInt(1, userId);
|
||||
statement.execute();
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
return true;
|
||||
} finally {
|
||||
close(statement);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user