diff --git a/.mailmap b/.mailmap new file mode 100644 index 000000000..2141dc400 --- /dev/null +++ b/.mailmap @@ -0,0 +1,5 @@ +Shoghi Cervantes +Shoghi Cervantes Shoghi Cervantes +Brandon V +Michael Yoo Michael Yoo +Michael Yoo Michael Yoo \ No newline at end of file diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 36f90e127..4463c1056 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1368,7 +1368,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $this->setRotation($packet->yaw, $packet->pitch); //$this->inBlock = $this->checkObstruction($this->x, ($this->boundingBox->minY + $this->boundingBox->maxY) / 2, $this->z); - $this->move($dx, $dy, $dz); + $revert = !$this->move($dx, $dy, $dz); $diffX = $this->x - $newPos->x; $diffZ = $this->z - $newPos->z; diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 49f6bd23f..f6520a153 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -715,7 +715,7 @@ abstract class Entity extends Position implements Metadatable{ //$collision = []; //$this->checkBlockCollision($collision); if($dx == 0 and $dz == 0 and $dy == 0){ - return; + return true; } //if($this->inBlock){ //TODO: noclip @@ -887,8 +887,11 @@ abstract class Entity extends Position implements Metadatable{ ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2 ); + $result = true; + if(!$this->setPosition($pos)){ $this->boundingBox->setBB($axisalignedbb); + $result = false; }else{ if($this instanceof Player){ @@ -922,6 +925,8 @@ abstract class Entity extends Position implements Metadatable{ //TODO: vehicle collision events (first we need to spawn them!) Timings::$entityMoveTimer->stopTiming(); + + return $result; //} } diff --git a/src/pocketmine/event/block/BlockEvent.php b/src/pocketmine/event/block/BlockEvent.php index e40e05f33..c2ac0eb47 100644 --- a/src/pocketmine/event/block/BlockEvent.php +++ b/src/pocketmine/event/block/BlockEvent.php @@ -38,6 +38,9 @@ abstract class BlockEvent extends Event{ $this->block = $block; } + /** + * @return Block + */ public function getBlock(){ return $this->block; } diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 12066e394..af0e66f31 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -913,6 +913,7 @@ class Level implements ChunkManager, Metadatable{ } $this->changedBlocks[$index][$Y][] = clone $block; } + if($update === true){ $this->updateAround($pos, self::BLOCK_UPDATE_NORMAL); $block->onUpdate(self::BLOCK_UPDATE_NORMAL); diff --git a/src/pocketmine/network/RakLibInterface.php b/src/pocketmine/network/RakLibInterface.php index b6ad89bba..89c989aa3 100644 --- a/src/pocketmine/network/RakLibInterface.php +++ b/src/pocketmine/network/RakLibInterface.php @@ -97,8 +97,6 @@ class RakLibInterface implements ServerInstance, SourceInterface{ /** @var ServerHandler */ private $interface; - private $tickTask; - private $upload = 0; private $download = 0; @@ -109,7 +107,6 @@ class RakLibInterface implements ServerInstance, SourceInterface{ $server = new RakLibServer($this->server->getLogger(), $this->server->getLoader(), $this->server->getPort(), $this->server->getIp() === "" ? "0.0.0.0" : $this->server->getIp()); $this->interface = new ServerHandler($server, $this); $this->setName($this->server->getMotd()); - $this->tickTask = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this, "doTick"]), 1); } public function doTick(){ @@ -124,6 +121,8 @@ class RakLibInterface implements ServerInstance, SourceInterface{ } } + $this->doTick(); + return $work; } @@ -147,12 +146,10 @@ class RakLibInterface implements ServerInstance, SourceInterface{ } public function shutdown(){ - $this->tickTask->cancel(); $this->interface->shutdown(); } public function emergencyShutdown(){ - $this->tickTask->cancel(); $this->interface->emergencyShutdown(); } diff --git a/src/pocketmine/permission/Permissible.php b/src/pocketmine/permission/Permissible.php index 777337fb8..7b59a2ac0 100644 --- a/src/pocketmine/permission/Permissible.php +++ b/src/pocketmine/permission/Permissible.php @@ -66,7 +66,6 @@ interface Permissible extends ServerOperator{ public function recalculatePermissions(); /** - * TODO: Check this * @return Permission[] */ public function getEffectivePermissions(); diff --git a/src/pocketmine/permission/PermissibleBase.php b/src/pocketmine/permission/PermissibleBase.php index 371c1ab8a..ae1218cea 100644 --- a/src/pocketmine/permission/PermissibleBase.php +++ b/src/pocketmine/permission/PermissibleBase.php @@ -194,10 +194,10 @@ class PermissibleBase implements Permissible{ * @param bool $invert * @param PermissionAttachment $attachment */ - public function calculateChildPermissions(array $children, $invert, $attachment){ - foreach(array_keys($children) as $name){ + private function calculateChildPermissions(array $children, $invert, $attachment){ + foreach($children as $name => $v){ $perm = Server::getInstance()->getPluginManager()->getPermission($name); - $value = $invert === true ? !$children[$name] : $children[$name]; + $value = ($v xor $invert); $this->permissions[$name] = new PermissionAttachmentInfo($this->parent, $name, $attachment, $value); Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent); diff --git a/src/pocketmine/permission/PermissionAttachment.php b/src/pocketmine/permission/PermissionAttachment.php index f1a93c309..75a8daba2 100644 --- a/src/pocketmine/permission/PermissionAttachment.php +++ b/src/pocketmine/permission/PermissionAttachment.php @@ -88,12 +88,47 @@ class PermissionAttachment{ return $this->permissions; } + /** + * @return bool[] + */ + public function clearPermissions(){ + $this->permissions = []; + $this->permissible->recalculatePermissions(); + } + + /** + * @param bool[] $permissions + */ + public function setPermissions(array $permissions){ + foreach($permissions as $key => $value){ + $this->permissions[$key] = (bool) $value; + } + $this->permissible->recalculatePermissions(); + } + + /** + * @param string[] $permissions + */ + public function unsetPermissions(array $permissions){ + foreach($permissions as $node){ + unset($this->permissions[$node]); + } + $this->permissible->recalculatePermissions(); + } + /** * @param string|Permission $name * @param bool $value */ public function setPermission($name, $value){ - $this->permissions[$name instanceof Permission ? $name->getName() : $name] = $value; + $name = $name instanceof Permission ? $name->getName() : $name; + if(isset($this->permissions[$name])){ + if($this->permissions[$name] === $value){ + return; + } + unset($this->permissions[$name]); //Fixes children getting overwritten + } + $this->permissions[$name] = $value; $this->permissible->recalculatePermissions(); } @@ -101,7 +136,11 @@ class PermissionAttachment{ * @param string|Permission $name */ public function unsetPermission($name){ - unset($this->permissions[$name instanceof Permission ? $name->getName() : $name]); + $name = $name instanceof Permission ? $name->getName() : $name; + if(isset($this->permissions[$name])){ + unset($this->permissions[$name]); + $this->permissible->recalculatePermissions(); + } } /** diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index 2fa15b231..98011d421 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -435,6 +435,9 @@ class PluginManager{ if(isset($this->permSubs[$permission])){ $this->permSubs[$permission][spl_object_hash($permissible)]->release(); unset($this->permSubs[$permission][spl_object_hash($permissible)]); + if(count($this->permSubs[$permission]) === 0){ + unset($this->permSubs[$permission]); + } } }