i used sleep to wait 1 second in interact event but it wait and then use all code PHP: public function onInteract(PlayerInteractEvent $event){ $block = $event->getBlock(); $player = $event->getPlayer(); $inventory = $player->getInventory(); if ($block->getId() === Block::CHEST) { if ($inventory->contains(new Emerald(0, 1))) { $event->setCancelled(); $player->sendMessage("§6[MineDox] §aOpening crate chest..."); sleep(1); $player->sendMessage("§a3"); sleep(1); $player->sendMessage("§a2"); sleep(1); $player->sendMessage("§a1"); $level = $player->getLevel(); $x = $block->getX(); $y = $block->getY(); $z = $block->getZ(); $r = 0; $g = 255; $b = 255; $center = new Vector3($x + 1, $y, $z); $radius = 0.5; $count = 100; $particle = new DustParticle($center, $r, $g, $b, 1); for ($yaw = 0, $y = $center->y; $y < $center->y + 4; $yaw += (M_PI * 2) / 20, $y += 1 / 20) { $x = -sin($yaw) + $center->x; $z = cos($yaw) + $center->z; $particle->setComponents($x, $y, $z); $level->addParticle($particle);
YAAY another post to be moved to facepalm http://php.net/manual/en/function.sleep.php READ! D E L A Y S execution. That means everything else also gets stopped. Events aren't in another thread. Please search the forums on how to create Delayed/Repeating tasks.