mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-16 21:21:23 +01:00
Added '@a' to AdminResetsResetCommand so that we can reset everyone
This commit is contained in:
parent
9545c74833
commit
4b4ee1646e
@ -1,13 +1,16 @@
|
|||||||
package world.bentobox.bentobox.api.commands.admin.resets;
|
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.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class AdminResetsResetCommand extends CompositeCommand {
|
public class AdminResetsResetCommand extends ConfirmableCommand {
|
||||||
|
|
||||||
public AdminResetsResetCommand(CompositeCommand parent) {
|
public AdminResetsResetCommand(CompositeCommand parent) {
|
||||||
super(parent, "reset");
|
super(parent, "reset");
|
||||||
@ -26,14 +29,27 @@ public class AdminResetsResetCommand extends CompositeCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID target = getPlayers().getUUID(args.get(0));
|
// Check if this is @a - therefore, we're resetting everyone's resets :)
|
||||||
if (target == null) {
|
if (args.get(0).equalsIgnoreCase("@a")) {
|
||||||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
|
this.askConfirmation(user, () -> {
|
||||||
return false;
|
// Set the reset epoch to now
|
||||||
} else {
|
getIWM().setResetEpoch(getWorld());
|
||||||
getPlayers().setResets(getWorld(), target, 0);
|
// Reset all current players
|
||||||
user.sendMessage("general.success");
|
Bukkit.getOnlinePlayers().stream().map(Player::getUniqueId).filter(getPlayers()::isKnown).forEach(u -> getPlayers().setResets(getWorld(), u, 0));
|
||||||
|
user.sendMessage("general.success");
|
||||||
|
});
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user