mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-02 21:41:28 +01:00
Added transaction wait to web delete command.
This should move "success" message to after the process has completed. Same treatment done to manage clear, manage remove and web register commands. Affects issues: - Close #1095
This commit is contained in:
parent
21fe36407e
commit
c6d18d186d
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.WebUserQueries;
|
||||
@ -41,6 +42,7 @@ import com.djrapitops.plugin.utilities.Verify;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* Command for registering web users.
|
||||
@ -164,12 +166,15 @@ public class RegisterCommand extends CommandNode {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_WEB_USER_EXISTS));
|
||||
return;
|
||||
}
|
||||
database.executeTransaction(new RegisterWebUserTransaction(webUser));
|
||||
database.executeTransaction(new RegisterWebUserTransaction(webUser))
|
||||
.get(); // Wait for completion
|
||||
|
||||
sender.sendMessage(locale.getString(CommandLang.WEB_USER_REGISTER_SUCCESS, userName));
|
||||
sendLink(sender);
|
||||
logger.info(locale.getString(CommandLang.WEB_USER_REGISTER_NOTIFY, userName, webUser.getPermLevel()));
|
||||
} catch (Exception e) {
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (DBOpException | ExecutionException e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
});
|
||||
|
@ -39,6 +39,7 @@ import com.djrapitops.plugin.utilities.Verify;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* This manage SubCommand is used to clear a database of all data.
|
||||
@ -101,11 +102,12 @@ public class ManageClearCommand extends CommandNode {
|
||||
processing.submitCritical(() -> {
|
||||
try {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
||||
database.executeTransaction(new RemoveEverythingTransaction());
|
||||
|
||||
database.executeTransaction(new RemoveEverythingTransaction())
|
||||
.get(); // Wait for completion
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (DBOpException e) {
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (DBOpException | ExecutionException e) {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* This manage subcommand is used to remove a single player's data from the
|
||||
@ -119,11 +120,12 @@ public class ManageRemoveCommand extends CommandNode {
|
||||
}
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
||||
db.executeTransaction(new RemovePlayerTransaction(playerUUID));
|
||||
|
||||
db.executeTransaction(new RemovePlayerTransaction(playerUUID))
|
||||
.get(); // Wait for completion
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (DBOpException e) {
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (DBOpException | ExecutionException e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
}
|
||||
|
@ -91,7 +91,9 @@ public class WebDeleteCommand extends CommandNode {
|
||||
sender.sendMessage("§c[Plan] User Doesn't exist.");
|
||||
return;
|
||||
}
|
||||
db.executeTransaction(new RemoveWebUserTransaction(user));
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
db.executeTransaction(new RemoveWebUserTransaction(user))
|
||||
.get(); // Wait for completion
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
|
Loading…
Reference in New Issue
Block a user