mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Add confirmation prompts to /delhome all and /delwarp all
This commit is contained in:
1 parent
d3b325c56b
commit
fde3736eb3
2 files changed
+56
-33
No files matched your search
@@ -21,8 +21,9 @@ public class DelWarpCommand extends CommandBase implements TabCompletable {
|
||||
|
||||
@Override
|
||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
if (args.length == 1) { //todo delwarp all
|
||||
if (args.length <= 2) {
|
||||
final String warpName = args[0];
|
||||
final boolean confirm = args.length == 2 && args[1].equalsIgnoreCase("confirm");
|
||||
plugin.getSavedPositionManager().deleteWarp(warpName).thenAccept(deleted -> {
|
||||
if (deleted) {
|
||||
plugin.getLocales().getLocale("warp_deleted", warpName)
|
||||
@@ -30,7 +31,7 @@ public class DelWarpCommand extends CommandBase implements TabCompletable {
|
||||
return;
|
||||
}
|
||||
if (warpName.equals("all")) {
|
||||
deleteAllWarps(onlineUser);
|
||||
deleteAllWarps(onlineUser, confirm);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,8 +48,9 @@ public class DelWarpCommand extends CommandBase implements TabCompletable {
|
||||
* Delete all the server warps
|
||||
*
|
||||
* @param deleter the player who is deleting the warps
|
||||
* @param confirm whether to skip the confirmation prompt
|
||||
*/
|
||||
private void deleteAllWarps(@NotNull OnlineUser deleter) {
|
||||
private void deleteAllWarps(@NotNull OnlineUser deleter, final boolean confirm) {
|
||||
plugin.getDatabase().getWarps().thenAccept(warps -> {
|
||||
if (warps.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_no_warps_set")
|
||||
@@ -56,6 +58,12 @@ public class DelWarpCommand extends CommandBase implements TabCompletable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm) {
|
||||
plugin.getLocales().getLocale("confirm_delete_all_warps")
|
||||
.ifPresent(deleter::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
final List<CompletableFuture<Boolean>> homeDeletionFuture = new ArrayList<>();
|
||||
for (final Warp toDelete : warps) {
|
||||
homeDeletionFuture.add(plugin.getSavedPositionManager().deleteWarp(toDelete.meta.name));
|
||||
|
||||
Reference in new issue
Block a user