Minor fixes

This commit is contained in:
Jesse Boyd
2016-10-14 15:14:08 +11:00
parent 5978c9c3c0
commit c97544d083
4 changed files with 45 additions and 20 deletions

View File

@ -197,7 +197,7 @@ public class MainCommand extends Command {
}
@Override
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
// Clear perm caching //
player.deleteMeta("perm");
// Optional command scope //
@ -223,6 +223,37 @@ public class MainCommand extends Command {
// Trim command
args = Arrays.copyOfRange(args, 1, args.length);
}
if (args.length >= 2 && args[0].charAt(0) == '-') {
switch (args[0].substring(1)) {
case "f":
confirm = new RunnableVal3<Command, Runnable, Runnable>() {
@Override
public void run(final Command cmd, final Runnable success, final Runnable failure) {
if (EconHandler.manager != null) {
PlotArea area = player.getApplicablePlotArea();
if (area != null) {
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId());
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != 0d && EconHandler.manager.getMoney(player) < price) {
if (failure != null) {
failure.run();
}
return;
}
}
}
if (success != null) {
success.run();
}
}
};
args = Arrays.copyOfRange(args, 1, args.length);
break;
default:
C.INVALID_COMMAND_FLAG.send(player);
return;
}
}
}
try {
super.execute(player, args, confirm, whenDone);

View File

@ -452,6 +452,10 @@ public enum C {
INVALID_PLAYER_WAIT("$2Player not found: $1%s$2, fetching it. Try again soon.", "Errors"),
INVALID_PLAYER("$2Player not found: $1%s$2.", "Errors"),
INVALID_PLAYER_OFFLINE("$2The player must be online: $1%s.", "Errors"),
/*
* Command flag
*/
INVALID_COMMAND_FLAG("$2Invalid command flag: %s0", "Errors"),
/*
* Unknown Error
*/