Hey(ツ) I want to attach a cooling time to the bow, but the message disappears halfway. I'd like to display messages in succession somehow. Can someone tell me? PHP: public function onShoot (EntityShootBowEvent $event){ $shooter = $event->getEntity(); if ($shooter instanceof Player) { $id = $shooter->getID(); $this->launch[$id] = (bool) true; if(!isset($this->shooted[$shooter->getName()])){ $this->shooted[$shooter->getName()] = time(); } if(isset($this->shooted[$shooter->getName()])){ $time = ($this->shooted[$shooter->getName()] + 4) - time(); if($time > 0){ switch ($time) { case '4': $tip = "CoolDownTime 4\n§4████████§r"; break; case '3.5': $tip = "CoolDownTime 3.5\n§4███████§a█§r"; break; case '3': $tip = "CoolDownTime 3\n§4██████§a██§r"; break; case '2.5': $tip = "CoolDownTime 2.5\n§4█████§a███§r"; break; case '2': $tip = "CoolDownTime 2\n§4████§a████§r"; break; case '1.5': $tip = "CoolDownTime 1.5\n§4███§a█████§r"; break; case '1': $tip = "CoolDownTime 1\n§4██§a██████§r"; break; case '0.5': $tip = "CoolDownTime 0.5\n§4█§a███████§r"; break; case '0': $tip = "CoolDownTime 0\n§a████████§r"; break; } $shooter->sendTip($tip); $event->setCancelled(); return; } if($time <= 0){ $this->shooted[$shooter->getName()] = time(); } } }}
You have to call scheduleRepeatingTask and scheduleDelayedTask Also , it should be cool down not cool time XD
PHP: public function onShoot (EntityShootBowEvent $event){ $shooter = $event->getEntity(); if(!$shooter instanceof Player) return; if(!isset($this->shot[$shooter->getName()])) { $this->shot[$shooter->getName()] = microtime(true); $event->setCancelled(); return; } $delta = microtime(true) - $this->shot[$shooter->getName()]; if($delta > 0) { $shooter->sendTip("Cooldown: ".round($delta, 2)." second(s)."); } else { unset($this->shot[$shooter->getName()]); }}