From df4585a847cd2bedeb2383362f95af5ce7d68aa1 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 21 Jun 2016 13:38:08 +1000 Subject: [PATCH] Check args for grant --- .../plot/commands/Grant.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Grant.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Grant.java index ed85ae33c..98d253688 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Grant.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Grant.java @@ -4,12 +4,14 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.object.RunnableVal2; +import com.intellectualcrafters.plot.object.RunnableVal3; import com.intellectualcrafters.plot.util.ByteArrayUtilities; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; +import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.CommandDeclaration; - import java.util.UUID; @CommandDeclaration( @@ -18,17 +20,22 @@ import java.util.UUID; usage = "/plot grant [player]", permission = "plots.grant", requiredType = RequiredType.NONE) -public class Grant extends SubCommand { +public class Grant extends Command { + + public Grant() { + super(MainCommand.getInstance(), true); + } @Override - public boolean onCommand(final PlotPlayer player, String[] args) { + public void execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { + checkTrue(args.length == 1, C.COMMAND_SYNTAX, getUsage()); final String arg0 = args[0].toLowerCase(); switch (arg0) { case "add": case "check": if (Permissions.hasPermission(player, "plots.grant." + arg0)) { C.NO_PERMISSION.send(player, "plots.grant." + arg0); - return false; + return; } if (args.length > 2) { break; @@ -36,7 +43,7 @@ public class Grant extends SubCommand { final UUID uuid = args.length == 2 ? UUIDHandler.getUUIDFromString(args[1]) : player.getUUID(); if (uuid == null) { C.INVALID_PLAYER.send(player, args[1]); - return false; + return; } MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal() { @Override @@ -51,10 +58,7 @@ public class Grant extends SubCommand { } } }); - return true; } C.COMMAND_SYNTAX.send(player, getUsage()); - return false; } - }