✔️ Provides generator-base command class for await-generator!
kim\present\awaitcommand\AwaitCommand
✔️ Provides implementation versions of PluginOwned!
kim\present\awaitcommand\AwaitPluginCommand
See Official Poggit Virion Documentation
Just extend AwaitCommand
or AwaitPluginCommand
instead of Command
!
And implement onExecute
method with Generator
return type!
<?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());
}
}
<?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{
// ...
}
}
Distributed under the MIT. See LICENSE for more information