mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Added InventoryOpenEvent and InventoryPickupItemEvent
This commit is contained in:
@ -23,6 +23,7 @@ namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\entity\EntityInventoryChangeEvent;
|
||||
use pocketmine\event\inventory\InventoryOpenEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\protocol\ContainerSetContentPacket;
|
||||
use pocketmine\network\protocol\ContainerSetSlotPacket;
|
||||
@ -348,6 +349,19 @@ abstract class BaseInventory implements Inventory{
|
||||
$this->setMaxStackSize($size);
|
||||
}
|
||||
|
||||
public function open(Player $who){
|
||||
$who->getServer()->getPluginManager()->callEvent($ev = new InventoryOpenEvent($this, $who));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
$this->onOpen($who);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function close(Player $who){
|
||||
$this->onClose($who);
|
||||
}
|
||||
|
||||
public function onOpen(Player $who){
|
||||
$this->viewers->attach($who);
|
||||
}
|
||||
|
Reference in New Issue
Block a user