Player: Cancel interaction on frames in spectator mode before calling the event, not after

This convention is used throughout the code to allow plugin developers to alter the behaviour of the event. In this case, it would instead produce unexpected behaviour when the event is not cancelled by a plugin.
This commit is contained in:
Dylan K. Taylor 2018-02-16 10:29:46 +00:00
parent 3b632c2870
commit a7396d7ae9

View File

@ -2823,12 +2823,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$tile = $this->level->getTileAt($packet->x, $packet->y, $packet->z);
if($tile instanceof ItemFrame){
$ev = new PlayerInteractEvent($this, $this->inventory->getItemInHand(), $tile->getBlock(), null, 5 - $tile->getBlock()->getDamage(), PlayerInteractEvent::LEFT_CLICK_BLOCK);
$this->server->getPluginManager()->callEvent($ev);
if($this->isSpectator()){
$ev->setCancelled();
}
$this->server->getPluginManager()->callEvent($ev);
if($ev->isCancelled()){
$tile->spawnTo($this);
return true;