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