-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
My command:
/**
* This is where all the arguments, permissions, sub-commands, etc would be registered
* @throws \CortexPE\Commando\exception\ArgumentOrderException
*/
protected function prepare(): void
{
$this->registerArgument(0, new BlockPositionArgument("position", false));
$this->registerArgument(1, new RawStringArgument("block", false));
}
/**
* @param CommandSender $sender
* @param string $aliasUsed
* @param BaseArgument[] $args
*/
public function onRun(CommandSender $sender, string $aliasUsed, array $args): void
{
if (isset($args["position"]) && isset($args["block"])) {
/**
* @var Vector3 $position
* @var string $block
*/
$position = $args["position"];
$block = $args["block"];
$sender->sendMessage(strval(extract($args)));
$sender->sendMessage(strval($position) . strval($block));
} else {
$this->sendUsage();
}
}
With some tests, i got these results:
block
[12:17:44] [Server thread/INFO]: Usage: /block <position:x y z> <block:string>
block 1
[12:17:45] [Server thread/INFO]: Invalid value '1' for argument #1
block 1 1
[12:17:46] [Server thread/INFO]: Invalid value '1' for argument #1
block 1 1 1
[12:17:49] [Server thread/INFO]: 2
[12:17:49] [Server thread/INFO]: Vector3(x=1,y=1,z=1)
block 1 1 1 tnt
[12:18:03] [Server thread/INFO]: 2
[12:18:03] [Server thread/INFO]: Vector3(x=1,y=1,z=1)tnt
IMO block 1 1 should say
Invalid value '1 1' for argument #1
block 1 1 1 Should still fail, since $block is not optional. isset returns true though.
block 1 1 1 tnt is the only correct syntax and correctly parsed
Metadata
Metadata
Assignees
Labels
No labels