Skip to content

Provides a generator-base command class for await-generator

License

Notifications You must be signed in to change notification settings

presentkim-pm/await-command

Repository files navigation

Poggit CI Stars License


Logo

await-command

Provides generator-base command class for await-generator!

View in Poggit · Report a bug · Request a feature

About The Project

✔️ Provides generator-base command class for await-generator!

  • kim\present\awaitcommand\AwaitCommand

✔️ Provides implementation versions of PluginOwned!

  • kim\present\awaitcommand\AwaitPluginCommand

Installation

See Official Poggit Virion Documentation


How to use?

Just extend AwaitCommand or AwaitPluginCommand instead of Command!
And implement onExecute method with Generator return type!

AwaitCommand

<?php

use kim\present\awaitcommand\AwaitCommand;
use pocketmine\command\CommandSender;
use pocketmine\plugin\Plugin;

class TestCommand extends AwaitCommand{
    public function __construct(){
        parent::__construct("test", "test command", "/test usage", ["t"]);
    }

    public function onExecute(CommandSender $sender, string $commandLabel, array $args) : \Generator{
        /** @var TestObject[] $rank */
        $test = yield from TestFactory::getTestObject();

        $sender->sendMessage("TestObject: " . $test->getName());
    }
}

AwaitPluginCommand

<?php

use kim\present\awaitcommand\AwaitPluginCommand;
use pocketmine\command\CommandSender;
use pocketmine\plugin\Plugin;

/** @extends AwaitPluginCommand<TestPLugin> */
class TestCommand extends AwaitPluginCommand{
    public function __construct(Plugin $plugin){
        parent::__construct($plugin, "test", "test command", "/test usage", ["t"]);
    }

    public function onExecute(CommandSender $sender, string $commandLabel, array $args) : \Generator{
        // ...
    }
}

License

Distributed under the MIT. See LICENSE for more information

About

Provides a generator-base command class for await-generator

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages