mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-13 03:41:03 +01:00
removeUserData methods now have no return value. No Exception -> success.
This commit is contained in:
parent
003c366fc7
commit
1f31f472bd
@ -85,11 +85,8 @@ public class ManageRemoveCommand extends SubCommand {
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
|
||||
try {
|
||||
// TODO Clear active session of user & start new one
|
||||
if (plugin.getDB().removeAccount(uuid)) {
|
||||
plugin.getDB().removeAccount(uuid);
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, plugin.getDB().getConfigName()));
|
||||
} else {
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
|
||||
|
@ -185,10 +185,9 @@ public abstract class Database {
|
||||
* Removes all data related to an account from the database.
|
||||
*
|
||||
* @param uuid UUID of the account.
|
||||
* @return Success of the removal.
|
||||
* @throws SQLException If a database error occurs.
|
||||
*/
|
||||
public abstract boolean removeAccount(UUID uuid) throws SQLException;
|
||||
public abstract void removeAccount(UUID uuid) throws SQLException;
|
||||
|
||||
/**
|
||||
* Used to clear all data from the database.
|
||||
|
@ -200,9 +200,9 @@ public abstract class SQLDB extends Database {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean removeAccount(UUID uuid) throws SQLException {
|
||||
public void removeAccount(UUID uuid) throws SQLException {
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
@ -215,15 +215,8 @@ public abstract class SQLDB extends Database {
|
||||
}
|
||||
|
||||
UserIDTable table = (UserIDTable) t;
|
||||
if (!table.removeUser(uuid)) {
|
||||
throw new IllegalStateException("Removal Failed");
|
||||
table.removeUser(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
return false;
|
||||
} finally {
|
||||
Benchmark.stop("Database", "Remove Account");
|
||||
setAvailable();
|
||||
|
@ -1,7 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.database.tables;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
|
||||
import main.java.com.djrapitops.plan.data.PlayerKill;
|
||||
@ -56,7 +55,7 @@ public class KillsTable extends UserIDTable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeUser(UUID uuid) {
|
||||
public void removeUser(UUID uuid) throws SQLException{
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
statement = prepareStatement("DELETE FROM " + tableName +
|
||||
@ -67,10 +66,6 @@ public class KillsTable extends UserIDTable {
|
||||
|
||||
statement.execute();
|
||||
commit(statement.getConnection());
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
Log.toLog(this.getClass().getName(), ex);
|
||||
return false;
|
||||
} finally {
|
||||
close(statement);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
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;
|
||||
@ -23,7 +22,7 @@ public abstract class UserIDTable extends Table {
|
||||
usersTable = db.getUsersTable();
|
||||
}
|
||||
|
||||
public boolean removeUser(UUID uuid) {
|
||||
public void removeUser(UUID uuid) throws SQLException {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
statement = prepareStatement("DELETE FROM " + tableName +
|
||||
@ -32,10 +31,6 @@ public abstract class UserIDTable extends Table {
|
||||
|
||||
statement.execute();
|
||||
commit(statement.getConnection());
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
Log.toLog(this.getClass().getName(), ex);
|
||||
return false;
|
||||
} finally {
|
||||
close(statement);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class UsersTable extends UserIDTable {
|
||||
* @return if the removal was successful.
|
||||
*/
|
||||
@Override
|
||||
public boolean removeUser(UUID uuid) {
|
||||
public void removeUser(UUID uuid) throws SQLException {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
statement = prepareStatement("DELETE FROM " + tableName + " WHERE (" + columnUUID + "=?)");
|
||||
@ -85,9 +85,6 @@ public class UsersTable extends UserIDTable {
|
||||
|
||||
statement.execute();
|
||||
commit(statement.getConnection());
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
return false;
|
||||
} finally {
|
||||
close(statement);
|
||||
}
|
||||
|
@ -210,7 +210,6 @@ public class WorldTimesTable extends UserIDTable {
|
||||
try {
|
||||
String worldIDColumn = worldTable + "." + worldTable.getColumnID();
|
||||
String worldNameColumn = worldTable + "." + worldTable.getColumnWorldName() + " as world_name";
|
||||
String sessionIDColumn = sessionsTable + "." + sessionsTable.getColumnID();
|
||||
statement = prepareStatement("SELECT " +
|
||||
"SUM(" + columnSurvival + ") as survival, " +
|
||||
"SUM(" + columnCreative + ") as creative, " +
|
||||
|
@ -0,0 +1,20 @@
|
||||
package main.java.com.djrapitops.plan.database.tables;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ActionsTest {
|
||||
|
||||
@Test
|
||||
public void getUnknownActionsEnum() {
|
||||
Actions action = Actions.getById(Integer.MIN_VALUE);
|
||||
assertEquals(Actions.UNKNOWN, action);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user