Skip to content

ParameterizedCommand 5.46.0 ​

interface · pocketmine\command\parameter\ParameterizedCommand · source

Implemented by commands that describe their syntax to clients. Bedrock clients use the overloads for autocompletion (e.g. target selector suggestions) and syntax hints. Commands without overloads are sent as taking free text.

The client also checks typed commands against the overloads before sending them, so the server always adds a free-text overload after these: commands keep accepting every syntax their execute() understands (unless the command implements ExhaustiveOverloads).

Plugin commands without this interface keep being sent with only the free-text overload. To describe a plugin command, extend \pocketmine\command\Command and implement this interface, e.g.:

php
final class HealCommand extends Command implements ParameterizedCommand{
    public function getOverloads() : array{
        return [
            [CommandParameter::target("player", optional: true)],
            [CommandParameter::enum("mode", "HealMode", ["full", "half"]), CommandParameter::target("player", optional: true)],
        ];
    }
    // execute()...
}

Enums are shared by name between all commands; reuse the names in CommandEnums (e.g. CommandParameter::item()) for vanilla kinds of values and prefix other names with the command name. The overloads are read whenever the command list is sent to a player (on join and when their permissions change).

Methods ​

getOverloads() ​

php
public function getOverloads() : array

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.