mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
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:
parent
3b632c2870
commit
a7396d7ae9
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user