From 761cd595145172ee8e87baeb0c2296811c893278 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 6 Oct 2014 11:22:59 +0200 Subject: [PATCH] Implemented flying protection --- src/pocketmine/Player.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 4eb4e5e83..1d09f58f8 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -175,6 +175,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ private $spawnPosition = null; private $inAction = false; + protected $inAirTicks = 0; + private $needACK = []; @@ -1176,6 +1178,18 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $this->processMovement(); $this->entityBaseTick(); + + if($this->onGround){ + $this->inAirTicks = 0; + }else{ + if($this->inAirTicks > 100 and $this->isSurvival() and !$this->isSleeping() and $this->spawned and !$this->server->getAllowFlight()){ + $this->kick("Flying is not enabled on this server"); + return false; + }else{ + ++$this->inAirTicks; + } + } + foreach($this->level->getNearbyEntities($this->boundingBox->grow(1, 1, 1), $this) as $entity){ if($entity instanceof Arrow and $entity->onGround and $this->motionX == 0 and $this->motionY == 0 and $this->motionZ == 0){ if($entity->dead !== true){