mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 11:45:31 +01:00
Moved the admin resets-related commands under their own node
Preparing #353. AdminClearresetsallCommand is deprecated with no current alternative right now.
This commit is contained in:
parent
a17d946349
commit
26c65f9b54
@ -10,6 +10,10 @@ import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
/**
|
||||
* @deprecated Renamed and moved to {@link world.bentobox.bentobox.api.commands.admin.resets.AdminResetsResetCommand}.
|
||||
*/
|
||||
@Deprecated
|
||||
public class AdminClearresetsCommand extends CompositeCommand {
|
||||
|
||||
public AdminClearresetsCommand(CompositeCommand parent) {
|
||||
|
@ -9,6 +9,11 @@ import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
|
||||
/**
|
||||
* Unlike {@link AdminClearresetsCommand}, this command will be removed.
|
||||
* We will be working on an alternative which will use {@link world.bentobox.bentobox.api.commands.admin.resets.AdminResetsResetCommand} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class AdminClearresetsallCommand extends ConfirmableCommand {
|
||||
|
||||
public AdminClearresetsallCommand(CompositeCommand parent) {
|
||||
|
@ -0,0 +1,28 @@
|
||||
package world.bentobox.bentobox.api.commands.admin.resets;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AdminResetsCommand extends CompositeCommand {
|
||||
|
||||
public AdminResetsCommand(CompositeCommand parent) {
|
||||
super(parent, "resets");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
setPermission("admin.resets");
|
||||
setDescription("commands.admin.resets.description");
|
||||
|
||||
new AdminResetsSetCommand(this);
|
||||
new AdminResetsResetCommand(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
showHelp(this, user);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package world.bentobox.bentobox.api.commands.admin.resets;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
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 AdminResetsResetCommand(CompositeCommand parent) {
|
||||
super(parent, "reset");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
setDescription("commands.admin.resets.reset.description");
|
||||
setParametersHelp("commands.admin.resets.reset.parameters");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
if (args.isEmpty() || args.size() != 1) {
|
||||
showHelp(this, user);
|
||||
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");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package world.bentobox.bentobox.api.commands.admin.resets;
|
||||
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AdminResetsSetCommand extends CompositeCommand {
|
||||
|
||||
public AdminResetsSetCommand(CompositeCommand parent) {
|
||||
super(parent, "set");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
setDescription("commands.admin.resets.set.description");
|
||||
setParametersHelp("commands.admin.resets.set.parameters");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
if (args.isEmpty() || args.size() != 2) {
|
||||
showHelp(this, user);
|
||||
return false;
|
||||
}
|
||||
|
||||
UUID target = getPlayers().getUUID(args.get(0));
|
||||
if (target == null) {
|
||||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
|
||||
} else if (!NumberUtils.isNumber(args.get(1)) || Integer.valueOf(args.get(1)) < 0) {
|
||||
user.sendMessage("general.errors.must-be-positive-number", TextVariables.NUMBER, args.get(1));
|
||||
} else {
|
||||
getPlayers().setResets(getWorld(), target, Integer.valueOf(args.get(1)));
|
||||
user.sendMessage("general.success");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -50,12 +50,14 @@ commands:
|
||||
help:
|
||||
parameters: ""
|
||||
description: "admin command"
|
||||
clearresets:
|
||||
parameters: "<player>"
|
||||
description: "clears player reset count for this world"
|
||||
cleared: "&2Resets cleared"
|
||||
clearresetsall:
|
||||
description: "clears all player reset counts for this world"
|
||||
resets:
|
||||
description: "edit resets of the players"
|
||||
set:
|
||||
description: "sets the resets of this player"
|
||||
parameters: "<player> <resets>"
|
||||
reset:
|
||||
description: "resets the resets of this player to 0"
|
||||
parameters: "<player>"
|
||||
team:
|
||||
add:
|
||||
parameters: "<owner> <player>"
|
||||
|
Loading…
Reference in New Issue
Block a user