简体   繁体   中英

PocketMine (PHP) Command Context possible?

As of 1.13 of Minecraft (and im not sure when it came out for bedrock) they added in the "command ui" with syntax and autofilling for commands (see below)

Command Syntax

I know on java edition it is possible to hijack the "Command Context" functions to create custom syntax for a command but on Bedrock it seems to all be stuck as [args: text] Is there any way to change that?

There is a very handy library/virion that handles all this for you. Take a look at https://github.com/CortexPE/Commando and if you need any examples you can look at https://github.com/CortexPE/Hierarchy . With this library you can add custom argument types.


<?php


namespace mohamed205\example\argument;


use CortexPE\Commando\args\StringEnumArgument;
use pocketmine\command\CommandSender;

class ExampleArgument extends StringEnumArgument
{
    protected const VALUES = [
        // put valid values for your argument here
    ];

    public function parse(string $argument, CommandSender $sender)
    {
        return $this->getValue($argument);
    }

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM