CortexPE/Commando

Adding a member argument to choose a user more easily

Opened this issue · 0 comments

Here is a file that you can add in the argument folder, it is a file that allows to obtain the player selector more easily.

<?php

namespace CortexPE\Commando\args;

use pocketmine\command\CommandSender;
use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;

class MemberArguement extends BaseArgument {

    public function getNetworkType(): int {
        return AvailableCommandsPacket::ARG_TYPE_TARGET;
    }

    public function getTypeName(): string {
        return "member";
    }

    public function canParse(string $testString, CommandSender $sender): bool {
        /** Définir le regex des nom d'utilisateur */
        return (bool)preg_match("/^(?!rcon|console)[a-zA-Z0-9_ ]{1,16}$/i", $testString);
    }

    public function parse(string $argument, CommandSender $sender): mixed {
        // TODO: Implement parse() method.
        return $argument;
    }

}