Implemented an InventoryEventProcessor, fixes #1986 (#2176)

* Implemented InventoryEventProcessor, fixes #1986
Event processors can now be registered and unregistered at will. Entity inventory/armor change events are now handled by event processors instead of the inventories themselves, which allows enabling/disabling the calling of these events at will.
This now avoids stupid things happening when initializing inventory contents, since the callers for those events are now registered _after_ the contents are initialized.
This commit is contained in:
Dylan K. Taylor
2018-06-09 17:37:10 +01:00
committed by GitHub
parent 8e5aca70b4
commit f6481eab8f
11 changed files with 159 additions and 43 deletions

View File

@ -31,7 +31,7 @@ use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
use pocketmine\network\mcpe\protocol\types\ContainerIds;
use pocketmine\Player;
class PlayerInventory extends EntityInventory{
class PlayerInventory extends BaseInventory{
/** @var Human */
protected $holder;
@ -43,7 +43,8 @@ class PlayerInventory extends EntityInventory{
* @param Human $player
*/
public function __construct(Human $player){
parent::__construct($player);
$this->holder = $player;
parent::__construct();
}
public function getName() : string{
@ -210,5 +211,4 @@ class PlayerInventory extends EntityInventory{
public function getHolder(){
return $this->holder;
}
}