Added InventoryCloseEvent

This commit is contained in:
Shoghi Cervantes 2014-05-27 01:30:24 +02:00
parent 6fcd5322d0
commit e1ccd7f9ea
3 changed files with 59 additions and 1 deletions

View File

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

View File

@ -0,0 +1,51 @@
<?php
/**
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\event\inventory;
use pocketmine\inventory\Inventory;
use pocketmine\Player;
/**
* Called when a entity is despawned
*/
class InventoryCloseEvent extends InventoryEvent{
public static $handlerList = null;
/** @var Player */
private $who;
/**
* @param Inventory $inventory
* @param Player $who
*/
public function __construct(Inventory $inventory, Player $who){
$this->who = $who;
parent::__construct($inventory);
}
/**
* @return Player
*/
public function getPlayer(){
return $this->who;
}
}

View File

@ -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
*/