From 4b4ee1646ee4da4a83a37c29b4f68b217f0853a7 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Thu, 3 Jan 2019 17:43:00 +0100 Subject: [PATCH] Added '@a' to AdminResetsResetCommand so that we can reset everyone --- .../admin/resets/AdminResetsResetCommand.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/admin/resets/AdminResetsResetCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/admin/resets/AdminResetsResetCommand.java index 7dbc3ebd0..e33579e80 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/admin/resets/AdminResetsResetCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/admin/resets/AdminResetsResetCommand.java @@ -1,13 +1,16 @@ package world.bentobox.bentobox.api.commands.admin.resets; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import world.bentobox.bentobox.api.commands.CompositeCommand; +import world.bentobox.bentobox.api.commands.ConfirmableCommand; import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.user.User; import java.util.List; import java.util.UUID; -public class AdminResetsResetCommand extends CompositeCommand { +public class AdminResetsResetCommand extends ConfirmableCommand { public AdminResetsResetCommand(CompositeCommand parent) { super(parent, "reset"); @@ -26,14 +29,27 @@ public class AdminResetsResetCommand extends CompositeCommand { return false; } - UUID target = getPlayers().getUUID(args.get(0)); - if (target == null) { - user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0)); - return false; - } else { - getPlayers().setResets(getWorld(), target, 0); - user.sendMessage("general.success"); + // Check if this is @a - therefore, we're resetting everyone's resets :) + if (args.get(0).equalsIgnoreCase("@a")) { + this.askConfirmation(user, () -> { + // Set the reset epoch to now + getIWM().setResetEpoch(getWorld()); + // Reset all current players + Bukkit.getOnlinePlayers().stream().map(Player::getUniqueId).filter(getPlayers()::isKnown).forEach(u -> getPlayers().setResets(getWorld(), u, 0)); + user.sendMessage("general.success"); + }); return true; + } else { + // Then, it may be a player + UUID target = getPlayers().getUUID(args.get(0)); + if (target == null) { + user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0)); + return false; + } else { + getPlayers().setResets(getWorld(), target, 0); + user.sendMessage("general.success"); + return true; + } } } }