Added InventoryAction->onPreExecute(), fixed PlayerDropItemEvent deleting items

This commit is contained in:
Dylan K. Taylor
2017-09-20 12:19:42 +01:00
parent 0262465a26
commit 55720d9f0a
4 changed files with 37 additions and 7 deletions

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\inventory\transaction\action;
use pocketmine\event\player\PlayerDropItemEvent;
use pocketmine\Player;
/**
@ -41,6 +42,15 @@ class DropItemAction extends InventoryAction{
return $this->sourceItem->isNull();
}
public function onPreExecute(Player $source) : bool{
$source->getServer()->getPluginManager()->callEvent($ev = new PlayerDropItemEvent($source, $this->targetItem));
if($ev->isCancelled()){
return false;
}
return true;
}
/**
* Drops the target item in front of the player.
*