Skip to content

Provides a fake asleep() function for await-generator

License

Notifications You must be signed in to change notification settings

presentkim-pm/await-sleep

Repository files navigation

Poggit CI Stars License


Logo

await-sleep

Provides a fake asleep() function for await-generator!

View in Poggit · Report a bug · Request a feature

About The Project

✔️ Register plugin to virion

  • kim\present\awaitsleep\AwaitCommand

✔️ Provides implementation versions of PluginOwned!

  • kim\present\awaitsleep\AwaitPluginCommand

Installation

See Official Poggit Virion Documentation


How to use?

First. register the plugin to virion for using task handler.

use kim\present\awaitsleep\AwaitSleep;
use pocketmine\plugin\PluginBase;

class TestPlugin extends PluginBase {
    public function onLoad() : void{
        AwaitSleep::register($this);
    }
}

Second. use AwaitSleep::sleep(int $ticks)!

use kim\present\awaitsleep\AwaitSleep;
use pocketmine\plugin\PluginBase;
use SOFe\AwaitGenerator\Await;

class TestPlugin extends PluginBase {
    public function onLoad() : void{
        AwaitSleep::register($this);
    }
    
    public function onEnable() : void{
        Await::g2c($this->test());
    }
    
    public function test() : \Generator{
        $this->getLogger()->info("Start");
        yield from AwaitSleep::sleep(20);
        $this->getLogger()->info("End");
    }
}

Third. use asleep(int $ticks) instead of Await::sleep(int $ticks)!

use kim\present\awaitsleep\AwaitSleep;
use pocketmine\plugin\PluginBase;
use SOFe\AwaitGenerator\Await;

use function kim\present\awaitsleep\asleep;

class TestPlugin extends PluginBase {
    public function onLoad() : void{
        AwaitSleep::register($this);
    }
    
    public function onEnable() : void{
        Await::g2c($this->test());
    }
    
    public function test() : \Generator{
        $this->getLogger()->info("Start");
        yield from asleep(20);
        $this->getLogger()->info("End");
    }
}

License

Distributed under the MIT. See LICENSE for more information

About

Provides a fake asleep() function for await-generator

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages