public function onBreak(BlockBreakEvent $event) { $island = $this->plugin->getIslandManager()->getOnlineIsland($event->getPlayer()->getLevel()->getName()); if($island instanceof Island) { if(!$event->getPlayer()->isOp() and !in_array(strtolower($event->getPlayer()->getName()), $island->getAllMembers())) { $event->getPlayer()->sendPopup(TextFormat::RED . "You must be part of this island to break here!"); $event->setCancelled(); } else { if($event->getBlock()->getId() == Block::COBBLESTONE) { - Please help me write code that when players block the block will drop random item ...
Pleeeease use code blocks... Spoiler: What's that? Please use: [PHP]Put your php code here[/PHP] or for normal code or files that aren't php: [CODE]Put normal code or file content (e.g. configs) here[/CODE]
PHP: if($event->getBlock()->getId() === 14) { $drops = array(); $drops[] = new Item(<blockID>, 0, <amount>); $event->setDrops($drops);}
If you want it to drop a random block/item: PHP: if($event->getBlock()->getId() === 14) { $random = mt_rand(1,435); $drops = array(); $drops[] = new Item($random, 0, <amount>); $event->setDrops($drops);}
This is the wrong section for development questions. To answer your question however, yes, lava and water can create set blocks.