Do not blanket-ban all inventory transactions in spectator mode, fixes #2627

instead, we cancel the appropriate events before they are called, so that plugins can uncancel them if they choose.
This commit is contained in:
Dylan K. Taylor
2020-05-31 16:32:06 +01:00
parent 3f07f06874
commit 42e14f749e
3 changed files with 6 additions and 11 deletions

View File

@ -1856,7 +1856,7 @@ class Level implements ChunkManager, Metadatable{
if($player !== null){
$ev = new PlayerInteractEvent($player, $item, $blockClicked, $clickVector, $face, PlayerInteractEvent::RIGHT_CLICK_BLOCK);
if($this->checkSpawnProtection($player, $blockClicked)){
if($this->checkSpawnProtection($player, $blockClicked) or $player->isSpectator()){
$ev->setCancelled(); //set it to cancelled so plugins can bypass this
}
@ -1909,7 +1909,7 @@ class Level implements ChunkManager, Metadatable{
if($player !== null){
$ev = new BlockPlaceEvent($player, $hand, $blockReplace, $blockClicked, $item);
if($this->checkSpawnProtection($player, $blockReplace)){
if($this->checkSpawnProtection($player, $blockReplace) or $player->isSpectator()){
$ev->setCancelled();
}