mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-11-21 18:16:07 +01:00
Merge pull request #330 from BentoBoxWorld/329_Add_+/-_option_to_handicap_setting
Adds a +/- tp the sethandicap admin command #329
This commit is contained in:
commit
dbf3621cee
@ -46,10 +46,20 @@ public class AdminSetInitialLevelCommand extends CompositeCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
String initialLevel = String.valueOf(addon.getManager().getInitialLevel(island));
|
||||
long lv = Long.parseLong(args.get(1));
|
||||
long initialLevel = addon.getManager().getInitialLevel(island);
|
||||
long lv = 0;
|
||||
if (args.get(1).startsWith("+")) {
|
||||
String change = args.get(1).substring(1);
|
||||
lv = initialLevel + Long.parseLong(change);
|
||||
} else if (args.get(1).startsWith("-")) {
|
||||
String change = args.get(1).substring(1);
|
||||
lv = initialLevel - Long.parseLong(change);
|
||||
} else {
|
||||
lv = Long.parseLong(args.get(1));
|
||||
}
|
||||
addon.getManager().setInitialIslandLevel(island, lv);
|
||||
user.sendMessage("admin.level.sethandicap.changed", TextVariables.NUMBER, initialLevel, "[new_number]", String.valueOf(lv));
|
||||
user.sendMessage("admin.level.sethandicap.changed", TextVariables.NUMBER, String.valueOf(initialLevel),
|
||||
"[new_number]", String.valueOf(lv));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -64,10 +74,20 @@ public class AdminSetInitialLevelCommand extends CompositeCommand {
|
||||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
|
||||
return false;
|
||||
}
|
||||
// Check value
|
||||
if (!Util.isInteger(args.get(1), true)) {
|
||||
user.sendMessage("admin.level.sethandicap.invalid-level");
|
||||
return false;
|
||||
// Check if this is a add or remove
|
||||
if (args.get(1).startsWith("+") || args.get(1).startsWith("-")) {
|
||||
String change = args.get(1).substring(1);
|
||||
if (!Util.isInteger(change, true)) {
|
||||
user.sendMessage("admin.level.sethandicap.invalid-level");
|
||||
return false;
|
||||
}
|
||||
// Value is okay
|
||||
} else {
|
||||
// Check value
|
||||
if (!Util.isInteger(args.get(1), true)) {
|
||||
user.sendMessage("admin.level.sethandicap.invalid-level");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Check island
|
||||
island = getAddon().getIslands().getIsland(getWorld(), targetUUID);
|
||||
|
@ -8,8 +8,12 @@ admin:
|
||||
parameters: "<player>"
|
||||
description: "calculate the island level for player"
|
||||
sethandicap:
|
||||
parameters: <player> <handicap>
|
||||
description: "set the island handicap, usually the level of the starter island"
|
||||
parameters: <player> [+/-]<handicap>
|
||||
description: |
|
||||
set or change the island *handicap*
|
||||
e.g. +10 will remove 10 levels,
|
||||
30 will set handicap to 30,
|
||||
-20 will add 20 levels
|
||||
changed: "&a Initial island handicap changed from [number] to [new_number]."
|
||||
invalid-level: "&c Invalid handicap. Use an integer."
|
||||
levelstatus:
|
||||
|
Loading…
Reference in New Issue
Block a user