mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-26 02:57:52 +01:00
Fixed SQLException related to Register concurrency. Fixed compile issues.
This commit is contained in:
parent
6ddaf8dec8
commit
555840c238
@ -5,6 +5,7 @@ import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.SubCommand;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
@ -12,6 +13,8 @@ import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.utilities.Check;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* This manage subcommand is used to clear a database of all data.
|
||||
*
|
||||
@ -80,12 +83,12 @@ public class ManageClearCommand extends SubCommand {
|
||||
try {
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
|
||||
|
||||
if (database.removeAllData()) {
|
||||
// TODO Clear active session of all users & start new ones
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_CLEAR_SUCCESS).toString());
|
||||
} else {
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
|
||||
}
|
||||
database.removeAllData();
|
||||
// TODO Clear active session of all users & start new ones
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_CLEAR_SUCCESS).toString());
|
||||
} catch (SQLException e) {
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
|
||||
Log.toLog(this.getClass().getSimpleName() + "/" + this.getTaskName(), e);
|
||||
} finally {
|
||||
this.cancel();
|
||||
}
|
||||
|
@ -195,9 +195,9 @@ public abstract class Database {
|
||||
* <p>
|
||||
* Uses DELETE * FROM table.
|
||||
*
|
||||
* @return Success of removal.
|
||||
* @throws SQLException if remove fails.
|
||||
*/
|
||||
public abstract boolean removeAllData();
|
||||
public abstract void removeAllData() throws SQLException;
|
||||
|
||||
/**
|
||||
* Used to fetch the saved UUIDs in the users table.
|
||||
|
@ -244,16 +244,12 @@ public abstract class SQLDB extends Database {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean removeAllData() {
|
||||
public void removeAllData() throws SQLException {
|
||||
setStatus("Clearing all data");
|
||||
try {
|
||||
for (Table table : getAllTablesInRemoveOrder()) {
|
||||
if (!table.removeAllData()) {
|
||||
return false;
|
||||
}
|
||||
table.removeAllData();
|
||||
}
|
||||
|
||||
return true;
|
||||
} finally {
|
||||
setAvailable();
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package main.java.com.djrapitops.plan.database.tables;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseException;
|
||||
import main.java.com.djrapitops.plan.database.Container;
|
||||
import main.java.com.djrapitops.plan.database.DBUtils;
|
||||
import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
||||
@ -134,12 +133,8 @@ public abstract class Table {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public void removeAllData() throws DatabaseException {
|
||||
try {
|
||||
execute("DELETE FROM " + tableName);
|
||||
} catch (SQLException e) {
|
||||
throw new DatabaseException("Failed to delete", e);
|
||||
}
|
||||
public void removeAllData() throws SQLException {
|
||||
execute("DELETE FROM " + tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,6 @@
|
||||
package main.java.com.djrapitops.plan.database.tables.move;
|
||||
|
||||
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseException;
|
||||
import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
||||
import main.java.com.djrapitops.plan.database.tables.ServerTable;
|
||||
import main.java.com.djrapitops.plan.database.tables.Table;
|
||||
@ -44,7 +43,7 @@ public class BatchOperationTable extends Table {
|
||||
throw new IllegalStateException("Method not supposed to be used on this table.");
|
||||
}
|
||||
|
||||
public void clearTable(Table table) throws DatabaseException {
|
||||
public void clearTable(Table table) throws SQLException {
|
||||
table.removeAllData();
|
||||
}
|
||||
|
||||
|
@ -95,9 +95,10 @@ public class PlanPlayerListener implements Listener {
|
||||
cache.cacheSession(uuid, Session.start(time, world, gm));
|
||||
|
||||
plugin.addToProcessQueue(
|
||||
new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline),
|
||||
new IPUpdateProcessor(uuid, ip),
|
||||
new NameProcessor(uuid, playerName, displayName)
|
||||
new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline,
|
||||
new IPUpdateProcessor(uuid, ip),
|
||||
new NameProcessor(uuid, playerName, displayName)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.database.tables.Actions;
|
||||
import main.java.com.djrapitops.plan.database.tables.UserInfoTable;
|
||||
import main.java.com.djrapitops.plan.database.tables.UsersTable;
|
||||
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
@ -26,13 +27,15 @@ public class RegisterProcessor extends PlayerProcessor {
|
||||
private final long time;
|
||||
private final int playersOnline;
|
||||
private final String name;
|
||||
private final Processor[] afterProcess;
|
||||
|
||||
public RegisterProcessor(UUID uuid, long registered, long time, String name, int playersOnline) {
|
||||
public RegisterProcessor(UUID uuid, long registered, long time, String name, int playersOnline, Processor... afterProcess) {
|
||||
super(uuid);
|
||||
this.registered = registered;
|
||||
this.time = time;
|
||||
this.playersOnline = playersOnline;
|
||||
this.name = name;
|
||||
this.afterProcess = afterProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -55,5 +58,6 @@ public class RegisterProcessor extends PlayerProcessor {
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
plugin.addToProcessQueue(afterProcess);
|
||||
}
|
||||
}
|
@ -68,7 +68,7 @@ public class ManageUtils {
|
||||
*/
|
||||
public static boolean clearAndCopy(Database clearAndCopyToDB, Database copyFromDB) {
|
||||
// try {
|
||||
clearAndCopyToDB.removeAllData();
|
||||
//clearAndCopyToDB.removeAllData();
|
||||
//TODO List<UserInfo> allUserData = copyFromDB.getUserDataForUUIDS(copyFromDB.getSavedUUIDs());
|
||||
// clearAndCopyToDB.saveMultipleUserData(allUserData);
|
||||
// TODO clearAndCopyToDB.getCommandUseTable().saveCommandUse(copyFromDB.getCommandUseTable().getCommandUse());
|
||||
|
Loading…
Reference in New Issue
Block a user