mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 05:05:18 +01:00
Fixed AdminDeathsRemoveCommand allowing to set a negative number of deaths
Also fixed the "[total]" textvariable not working in its success message
This commit is contained in:
parent
f8c4ea568f
commit
e20690935a
@ -38,8 +38,12 @@ public class AdminDeathsRemoveCommand extends CompositeCommand {
|
||||
} 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, getPlayers().getDeaths(getWorld(), target) - Integer.valueOf(args.get(1)));
|
||||
user.sendMessage("commands.admin.deaths.remove.success", TextVariables.NAME, args.get(0), TextVariables.NUMBER, args.get(1));
|
||||
// Make sure it cannot go under 0.
|
||||
int newDeaths = Math.max(getPlayers().getDeaths(getWorld(), target) - Integer.valueOf(args.get(1)), 0);
|
||||
getPlayers().setDeaths(getWorld(), target, newDeaths);
|
||||
user.sendMessage("commands.admin.deaths.remove.success",
|
||||
TextVariables.NAME, args.get(0), TextVariables.NUMBER, args.get(1),
|
||||
"[total]", String.valueOf(newDeaths));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user