Hi guys, I'm trying to delete a world inside to worlds folder, but it doesn't work, there isn't even a error message. PHP: $lvl = $player->getLevel(); $folder = $lvl->getProvider()->getPath(); $this->plugin->getServer()->unloadLevel($lvl); $server = $this->plugin->getServer()->getDataPath(); echo $folder; $player->teleport($this->plugin->getServer()->getDefaultLevel()->getSafeSpawn()); $this->plugin->getServer()->getScheduler()->scheduleDelayedTask(new DelayedDeleteDir($this->plugin, $folder), 40); PHP: <?phpnamespace CWTraining\tasks;use CWTraining\CWTraining;use pocketmine\scheduler\Task;class DelayedDeleteDir extends Task{ public $plugin; public $dir; public function __construct(CWTraining $plugin, string $dir) { $this->plugin = $plugin; } public function onRun(int $currentTick) { $this->plugin->delete_files($this->dir); }} PHP: public function delete_files($target) { if(is_dir($target)){ $files = glob( $target . '*', GLOB_MARK ); //GLOB_MARK adds a slash to directories returned foreach( $files as $file ) { $this->delete_files( $file ); } rmdir( $target ); } elseif(is_file($target)) { unlink( $target ); } } Please help, idk what I do wrong...
Solved with SkyZoneMC in a private discord chat. He was missing $this->dir = $dir; in his task constructor. PHP: public function __construct(CWTraining $plugin, string $dir) { $this->plugin = $plugin;}