$players = $sender->getServer()->getOnlinePlayers(); $sender->getServer()->getAsyncPool()->submitTask(new class($players) extends \pocketmine\scheduler\AsyncTask { private array $players; public function __construct(array $players){ $this->players = $players; } public function onRun() : void{ foreach($this->players as $player) $player->sendMessage("async"); } });