Added admin command to reset/set deaths

#76
* Added AdminDeathsCommand
* Added AdminDeathsResetCommand
* Added AdminDeathsSetCommand
* Updated en-US locale accordingly
* Added "general.errors.must-be-positive-number" to the en-US locale
* Fixed some formatting in the en-US locale
This commit is contained in:
Florian CUNY 2018-12-11 14:51:05 +01:00
parent 7a888fce95
commit 486de0dc19
4 changed files with 131 additions and 3 deletions

View File

@ -0,0 +1,31 @@
package world.bentobox.bentobox.api.commands.admin.deaths;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import java.util.List;
/**
* @author Poslovitch
*/
public class AdminDeathsCommand extends CompositeCommand {
public AdminDeathsCommand(CompositeCommand parent) {
super(parent, "deaths");
}
@Override
public void setup() {
setPermission("admin.deaths");
setDescription("commands.admin.deaths.description");
new AdminDeathsResetCommand(this);
new AdminDeathsSetCommand(this);
}
@Override
public boolean execute(User user, String label, List<String> args) {
showHelp(this, user);
return true;
}
}

View File

@ -0,0 +1,42 @@
package world.bentobox.bentobox.api.commands.admin.deaths;
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;
/**
* @author Poslovitch
*/
public class AdminDeathsResetCommand extends CompositeCommand {
public AdminDeathsResetCommand(AdminDeathsCommand parent) {
super(parent, "reset");
}
@Override
public void setup() {
setDescription("commands.admin.deaths.reset.description");
setParametersHelp("commands.admin.deaths.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().setDeaths(getWorld(), target, 0);
user.sendMessage("general.success");
return true;
}
}
}

View File

@ -0,0 +1,46 @@
package world.bentobox.bentobox.api.commands.admin.deaths;
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;
/**
* @author Poslovitch
*/
public class AdminDeathsSetCommand extends CompositeCommand {
public AdminDeathsSetCommand(AdminDeathsCommand parent) {
super(parent, "set");
}
@Override
public void setup() {
setDescription("commands.admin.deaths.set.description");
setParametersHelp("commands.admin.deaths.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().setDeaths(getWorld(), target, Integer.valueOf(args.get(1)));
user.sendMessage("general.success");
return true;
}
return false;
}
}

View File

@ -14,7 +14,7 @@ meta:
general:
success: "&aSuccess!"
errors:
command-cancelled: "&cCommand cancelled"
command-cancelled: "&cCommand cancelled."
no-permission: "&cYou don't have the permission to execute this command (&7[permission]&c)."
use-in-game: "&cThis command is only available in game."
no-team: "&cYou do not have a team!"
@ -32,6 +32,7 @@ general:
warp-not-safe: "&cThat warp is not safe right now!"
wrong-world: "&cYou are not in the right world to do that!"
you-must-wait: "&cYou must wait [number]s before you can do that command again."
must-be-positive-number: "&c[number] is not a valid positive number."
tips:
changing-obsidian-to-lava: "Changing obsidian back into lava. Be careful!"
@ -68,7 +69,7 @@ commands:
kick:
parameters: "<team player>"
description: "kick a player from a team"
cannot-kick-owner: "&cYou cannot kick the owner. Kick members first"
cannot-kick-owner: "&cYou cannot kick the owner. Kick members first."
admin-kicked: "&cThe admin kicked you from the team."
setowner:
parameters: "<player>"
@ -194,9 +195,17 @@ commands:
deleted-island: "&aIsland at &e[xyz] &ahas been successfully deleted."
why:
parameters: "<player>"
description: "Toggle console protection debug reporting"
description: "toggle console protection debug reporting"
turning-on: "Turning on console debug for [name]"
turning-off: "Turning off console debug for [name]"
deaths:
description: "edit deaths of players"
reset:
description: "resets deaths of the player"
parameters: "<player>"
set:
description: "sets deaths of the player"
parameters: "<player> <deaths>"
bentobox:
description: "BentoBox admin command"
about: