diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index decaefa3a0..3c2d603efd 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -25,6 +25,7 @@ use pocketmine\block\Block; use pocketmine\command\CommandSender; use pocketmine\entity\DroppedItem; use pocketmine\entity\Human; +use pocketmine\event\inventory\InventoryCloseEvent; use pocketmine\event\player\PlayerAchievementAwardedEvent; use pocketmine\event\player\PlayerChatEvent; use pocketmine\event\player\PlayerCommandPreprocessEvent; @@ -1986,6 +1987,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ break; } if(isset($this->windowIndex[$packet->windowid])){ + $this->server->getPluginManager()->callEvent(new InventoryCloseEvent($this->windowIndex[$packet->windowid], $this)); $this->removeWindow($this->windowIndex[$packet->windowid]); }else{ unset($this->windowIndex[$packet->windowid]); diff --git a/src/pocketmine/event/inventory/InventoryCloseEvent.php b/src/pocketmine/event/inventory/InventoryCloseEvent.php new file mode 100644 index 0000000000..6cab54dcb3 --- /dev/null +++ b/src/pocketmine/event/inventory/InventoryCloseEvent.php @@ -0,0 +1,51 @@ +who = $who; + parent::__construct($inventory); + } + + /** + * @return Player + */ + public function getPlayer(){ + return $this->who; + } + +} \ No newline at end of file diff --git a/src/pocketmine/event/inventory/InventoryEvent.php b/src/pocketmine/event/inventory/InventoryEvent.php index afcfc10412..479d344538 100644 --- a/src/pocketmine/event/inventory/InventoryEvent.php +++ b/src/pocketmine/event/inventory/InventoryEvent.php @@ -22,15 +22,20 @@ /** * Inventory related events */ -namespace pocketmine\event\player; +namespace pocketmine\event\inventory; use pocketmine\event\Event; +use pocketmine\inventory\Inventory; abstract class InventoryEvent extends Event{ /** @var Inventory */ protected $inventory; + public function __construct(Inventory $inventory){ + $this->inventory = $inventory; + } + /** * @return Inventory */