mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
InventoryAction: replace isValid() with validate() which throws TransactionValidationException
This commit is contained in:
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\inventory\transaction\action;
|
||||
|
||||
use pocketmine\event\player\PlayerDropItemEvent;
|
||||
use pocketmine\inventory\transaction\TransactionValidationException;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\player\Player;
|
||||
@ -37,8 +38,10 @@ class DropItemAction extends InventoryAction{
|
||||
parent::__construct(ItemFactory::air(), $targetItem);
|
||||
}
|
||||
|
||||
public function isValid(Player $source) : bool{
|
||||
return !$this->targetItem->isNull();
|
||||
public function validate(Player $source) : void{
|
||||
if($this->targetItem->isNull()){
|
||||
throw new TransactionValidationException("Cannot drop an empty itemstack");
|
||||
}
|
||||
}
|
||||
|
||||
public function onPreExecute(Player $source) : bool{
|
||||
|
Reference in New Issue
Block a user