Call PlayerInteractEventm when receiving ItemFrameDropItemPacket to allow plugins to prevent item frame item removal (#887)

This commit is contained in:
Muqsit Rayyan 2017-05-05 13:18:58 +03:00 committed by Dylan K. Taylor
parent c4f461f65d
commit 11f35d28c2

View File

@ -3240,7 +3240,14 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$tile = $this->level->getTile($this->temporalVector->setComponents($packet->x, $packet->y, $packet->z));
if($tile instanceof ItemFrame){
$ev = new PlayerInteractEvent($this, $this->inventory->getItemInHand(), $tile->getBlock(), 5 - $tile->getBlock()->getDamage(), PlayerInteractEvent::LEFT_CLICK_BLOCK);
$this->server->getPluginManager()->callEvent($ev);
if($this->isSpectator()){
$ev->setCancelled();
}
if($ev->isCancelled()){
$tile->spawnTo($this);
return true;
}