CortexPE / Commando

A Command Framework virion for PocketMine-MP
GNU Lesser General Public License v3.0
70 stars 53 forks source link

how to make a warps list arg? #27

Closed rjworks closed 4 years ago

rjworks commented 4 years ago

how to make a warps list arg? player type /warp and it shows all warps in my config

inxomnyaa commented 4 years ago

Create enum

class WarpEnumArgument extends StringEnumArgument
{
    public function getTypeName(): string
    {
        return "string";
    }

    public function parse(string $argument, CommandSender $sender)
    {
        return $argument;
    }

    public function getEnumValues(): array
    {
        return MyWarps::getWarps();
    }

    public function getEnumName(): string
    {
        return "warp";
    }
}

Your command:

    protected function prepare(): void {
...
        $this->registerArgument(0, new WarpEnumArgument("warp", false));
    }