Skip to content
Remminiscent edited this page Jun 27, 2026 · 3 revisions

Install

composer require remminiscent/pmcommandtree

Register

Call this once in your plugin:

use remmi\PMCommandTree\PMCommandTree;

protected function onEnable(): void
{
    PMCommandTree::register($this);
}

Basic Idea

Create a CommandRouteTree, set a root permission, add nodes, then register a RouteCommand.

$tree = new CommandRouteTree("example");
$root = $tree->getRoot();

$root->permission("example.command");

$root->then(
    CommandRouteNode::literal("say")->then(
        CommandRouteNode::argument("message", TextArgumentType::text())->exec(
            static function (CommandContext $context): CommandResult {
                $context->getSender()->sendMessage($context->getArg("message"));
                return $context->success();
            }
        )
    )
);

The builder API is fluent, so chaining and variables both work. Write routes whichever way you like.

Notes

  • Root command permissions must exist in plugin.yml.
  • Node permissions must also exist before calling permission().

Clone this wiki locally