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:
Florian CUNY 2018-12-29 10:52:13 +01:00
parent a17d946349
commit 26c65f9b54
6 changed files with 127 additions and 6 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}

View File

@ -50,12 +50,14 @@ commands:
help:
parameters: ""
description: "admin command"
clearresets:
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>"
description: "clears player reset count for this world"
cleared: "&2Resets cleared"
clearresetsall:
description: "clears all player reset counts for this world"
team:
add:
parameters: "<owner> <player>"