targetItem->isNull()){ throw new TransactionValidationException("Cannot drop an empty itemstack"); } } public function onPreExecute(Player $source) : bool{ $ev = new PlayerDropItemEvent($source, $this->targetItem); if($source->isSpectator()){ $ev->cancel(); } $ev->call(); if($ev->isCancelled()){ return false; } return true; } /** * Drops the target item in front of the player. */ public function execute(Player $source) : void{ $source->dropItem($this->targetItem); } }