Removed UserIDTable and Deprecated Column variables

This commit is contained in:
Rsl1122 2018-12-13 21:04:11 +02:00
parent e9a2a3b1e2
commit 3ae40e4bb3
11 changed files with 6 additions and 125 deletions

View File

@ -21,7 +21,6 @@ import com.djrapitops.plan.system.database.databases.sql.SQLDB;
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
import com.djrapitops.plan.system.database.databases.sql.tables.NicknamesTable;
import com.djrapitops.plan.system.database.databases.sql.tables.UserIDTable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -45,6 +44,11 @@ public class NicknameLastSeenPatch extends Patch {
NicknamesTable.Col.LAST_USED + " bigint NOT NULL DEFAULT '0'"
);
if (hasColumn(NicknamesTable.TABLE_NAME, NicknamesTable.Col.UUID.get())) {
// NicknamesOptimizationPatch makes this patch incompatible with newer patch versions.
return;
}
// Create table if has failed already
db.executeUnsafe("CREATE TABLE IF NOT EXISTS plan_actions " +
"(action_id integer, date bigint, server_id integer, user_id integer, additional_info varchar(1))");
@ -70,7 +74,7 @@ public class NicknameLastSeenPatch extends Patch {
while (set.next()) {
long date = set.getLong("date");
int userID = set.getInt(UserIDTable.Col.USER_ID.get());
int userID = set.getInt("user_id");
int serverID = set.getInt("server_id");
UUID serverUUID = serverUUIDsByID.get(serverID);
Nickname nick = new Nickname(set.getString("additional_info"), date, serverUUID);

View File

@ -243,8 +243,6 @@ public class GeoInfoTable extends UserUUIDTable {
public enum Col implements Column {
ID("id"),
@Deprecated
USER_ID(UserIDTable.Col.USER_ID.get()),
UUID(UserUUIDTable.Col.UUID.get()),
IP("ip"),
IP_HASH("ip_hash"),

View File

@ -324,14 +324,8 @@ public class KillsTable extends UserUUIDTable {
public enum Col implements Column {
ID("id"),
@Deprecated
KILLER_ID("killer_id"),
KILLER_UUID("killer_uuid"),
@Deprecated
VICTIM_ID("victim_id"),
VICTIM_UUID("victim_uuid"),
@Deprecated
SERVER_ID("server_id"),
SERVER_UUID("server_uuid"),
SESSION_ID("session_id"),
WEAPON("weapon"),

View File

@ -275,11 +275,7 @@ public class NicknamesTable extends UserUUIDTable {
public enum Col implements Column {
ID("id"),
@Deprecated
USER_ID(UserIDTable.Col.USER_ID.get()),
UUID(UserUUIDTable.Col.UUID.get()),
@Deprecated
SERVER_ID("server_id"),
SERVER_UUID("server_uuid"),
NICKNAME("nickname"),
LAST_USED("last_used");

View File

@ -193,11 +193,7 @@ public class PingTable extends UserUUIDTable {
public enum Col implements Column {
ID("id"),
@Deprecated
USER_ID(UserIDTable.Col.USER_ID.get()),
UUID(UserUUIDTable.Col.UUID.get()),
@Deprecated
SERVER_ID("server_id"),
SERVER_UUID("server_uuid"),
DATE("date"),
MAX_PING("max_ping"),

View File

@ -598,12 +598,8 @@ public class SessionsTable extends UserUUIDTable {
}
public enum Col implements Column {
@Deprecated
USER_ID(UserIDTable.Col.USER_ID.get()),
UUID(UserUUIDTable.Col.UUID.get()),
ID("id"),
@Deprecated
SERVER_ID("server_id"),
SERVER_UUID("server_uuid"),
SESSION_START("session_start"),
SESSION_END("session_end"),

View File

@ -1,73 +0,0 @@
/*
* This file is part of Player Analytics (Plan).
*
* Plan is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License v3 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Plan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
*/
package com.djrapitops.plan.system.database.databases.sql.tables;
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
import com.djrapitops.plan.system.database.databases.sql.statements.Column;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.UUID;
/**
* Represents a Table that uses UsersTable IDs to get their data.
*
* @author Rsl1122
* @since 3.7.0
*/
@Deprecated
public abstract class UserIDTable extends Table {
public enum Col implements Column {
USER_ID("user_id");
private final String column;
Col(String column) {
this.column = column;
}
@Override
public String get() {
return toString();
}
@Override
public String toString() {
return column;
}
}
protected final UsersTable usersTable;
public UserIDTable(String name, SQLDB db) {
super(name, db);
usersTable = db.getUsersTable();
}
public void removeUser(UUID uuid) {
String sql = "DELETE FROM " + tableName + " WHERE (" + Col.USER_ID + "=" + usersTable.statementSelectID + ")";
execute(new ExecStatement(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, uuid.toString());
}
});
}
}

View File

@ -362,11 +362,7 @@ public class UserInfoTable extends UserUUIDTable {
public enum Col implements Column {
ID("id"),
@Deprecated
USER_ID(UserIDTable.Col.USER_ID.get()),
UUID(UserUUIDTable.Col.UUID.get()),
@Deprecated
SERVER_ID("server_id"),
SERVER_UUID("server_uuid"),
REGISTERED("registered"),
OP("opped"),

View File

@ -380,26 +380,6 @@ public class UsersTable extends UserUUIDTable {
});
}
@Deprecated
public Map<Integer, UUID> getUUIDsByID() {
String sql = Select.from(tableName, Col.ID, Col.UUID).toString();
return query(new QueryAllStatement<Map<Integer, UUID>>(sql, 20000) {
@Override
public Map<Integer, UUID> processResults(ResultSet set) throws SQLException {
Map<Integer, UUID> uuidsByID = new TreeMap<>();
while (set.next()) {
int id = set.getInt(Col.ID.get());
UUID uuid = UUID.fromString(set.getString(Col.UUID.get()));
uuidsByID.put(id, uuid);
}
return uuidsByID;
}
});
}
/**
* Gets the {@code UUID} and the name of the player mapped to the user ID
*

View File

@ -178,8 +178,6 @@ public class WorldTable extends Table {
public enum Col implements Column {
ID("id"),
@Deprecated
SERVER_ID("server_id"),
SERVER_UUID("server_uuid"),
NAME("world_name");

View File

@ -386,11 +386,7 @@ public class WorldTimesTable extends UserUUIDTable {
public enum Col implements Column {
ID("id"),
@Deprecated
USER_ID(UserIDTable.Col.USER_ID.get()),
UUID(UserUUIDTable.Col.UUID.get()),
@Deprecated
SERVER_ID("server_id"),
SERVER_UUID("server_uuid"),
SESSION_ID("session_id"),
WORLD_ID("world_id"),