Greetings, I'm writing a plugin which allow players destroy certain blocks in worlds. In the first world players allowed to destroy only the oak, birch and pine logs. The code works fine. I just copied the code and wanted to do the same with ores too for another world, but it doesn't work and I don't know why. Hope somene could help. PHP: public function blockBreakOnWoodWorld(BlockBreakEvent $event){ $wood = array("17", "17:1", "17:2"); $block = $event->getBlock(); $player = $event->getPlayer(); // WoodWorld if(!$player->hasPermission("protection.bypass")){ if($event->getPlayer()->getLevel()->getName() === "woodworld"){ if($block->getId() != $wood[0] && $wood[1] && $wood[2]){ $event->setCancelled(); } if($event->isCancelled()){ $player->sendMessage("You can't destroy this block!"); } } } } PHP: public function blockBreakOnMinerWorld(BlockBreakEvent $event){ $fem = array("1", "3", "13", "14", "15", "16", "21", "73", "56"); $block = $event->getBlock(); $player = $event->getPlayer(); // MinerWorld if(!$player->hasPermission("protection.bypass")){ if($event->getPlayer()->getLevel()->getName() === "minerworld"){ if($block->getId() != $fem[0] && $fem[1] && $fem[2] && $fem[3] && $fem[4] && $fem[5] && $fem[6] && $fem[7] && $fem[8]){ $event->setCancelled(); } if($event->isCancelled()){ $player->sendMessage("You can't destroy this block!"); } } } }
PHP: public function onBreak(BlockBreakEvent $e){$player = $e->getPlayer();$b = $e->getBlock();$allowedBlocksIds = [1, 3, 13];////write OTHERS IDsif(!in_array($b->getId(), $allowedBlocksIds)){ $e->setCancelled(); } }