Use DataPacketReceiveEvent to capture PlayerActionPacket of action PlayerActionPacket::ACTION_START_BREAK, store the time somewhere under player's name Then at BlockBreakEvent, compare the time stored of player with current time
Ah, I tried and it is working But can anything improve? PHP: public function startBreak(DataPacketReceiveEvent $e){ $p = $e->getPlayer(); $time = $this->break[strtolower($p->getName())][0]; $pk = $e->getPacket(); if($pk instanceof PlayerActionPacket){ if($pk->action == 0){ if(isset($this->break[strtolower($p->getName())][0])){ $this->break[strtolower($p->getName())[1]]; $p->sendMessage("Debug"); }else{ $this->break[strtolower($p->getName())][0]; } } }}public function onFastBreak(BlockBreakEvent $event){ $player = $event->getPlayer(); $block = $event->getBlock(); $time = $this->break[strtolower($player->getName())][0]; if (isset($this->break[strtolower($player->getName())])) { $time = $this->break[strtolower($player->getName())][0]; $oldbreak = $this->break[strtolower($player->getName())][1]; if ($block == $oldbreak || $this->getServer()->getTick() - 10 < $time) { $player->kick("§eFastBreak not allowed", false); $event->setCancelled(); return false; } $this->break[strtolower($player->getName())] = array($this->getServer()->getTick(), $block); return true; } $this->break[strtolower($player->getName())] = array($this->getServer()->getTick(), $block); return true; }
Player->lastBreak will be useful. https://github.com/pmmp/PocketMine-...798d159a4a094/src/pocketmine/Player.php#L2132 https://github.com/pmmp/PocketMine-...59a4a094/src/pocketmine/level/Level.php#L1539