Can i share variables from Main to Task? For example, i have $php on Main and i want to use that variable on Task too
You send the variable when you're sending the task and you then construct that variable in your task class. PHP: $task = new Task($this,$player);//Player is the variable i want in my task. Also you can put more variables here. $this->getScheduler()->scheduleDelayedTask($task,20); And then construct it PHP: public function __construct($plugin,$player){ $this->plugin = $plugin; $this->player = $player;//here } public function onRun(int $tick){ //do whatever var_dump($this->player->getName()); }