Added InventoryOpenEvent and InventoryPickupItemEvent

This commit is contained in:
Shoghi Cervantes
2014-05-27 01:44:56 +02:00
parent e1ccd7f9ea
commit d92c5332da
5 changed files with 186 additions and 12 deletions

View File

@ -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);
}