mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Destroy cycles that reference player for faster collection
This commit is contained in:
@ -31,7 +31,7 @@ class PermissibleBase implements Permissible{
|
||||
private $opable = null;
|
||||
|
||||
/** @var Permissible */
|
||||
private $parent;
|
||||
private $parent = null;
|
||||
|
||||
/**
|
||||
* @var PermissionAttachment[]
|
||||
@ -50,11 +50,14 @@ class PermissibleBase implements Permissible{
|
||||
$this->opable = $opable;
|
||||
if($opable instanceof Permissible){
|
||||
$this->parent = $opable;
|
||||
}else{
|
||||
$this->parent = $this;
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct(){
|
||||
$this->parent = null;
|
||||
$this->opable = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
@ -130,7 +133,7 @@ class PermissibleBase implements Permissible{
|
||||
throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
|
||||
}
|
||||
|
||||
$result = new PermissionAttachment($plugin, $this->parent);
|
||||
$result = new PermissionAttachment($plugin, $this->parent !== null ? $this->parent : $this);
|
||||
$this->attachments[spl_object_hash($result)] = $result;
|
||||
if($name !== null and $value !== null){
|
||||
$result->setPermission($name, $value);
|
||||
@ -168,12 +171,12 @@ class PermissibleBase implements Permissible{
|
||||
|
||||
$this->clearPermissions();
|
||||
$defaults = Server::getInstance()->getPluginManager()->getDefaultPermissions($this->isOp());
|
||||
Server::getInstance()->getPluginManager()->subscribeToDefaultPerms($this->isOp(), $this->parent);
|
||||
Server::getInstance()->getPluginManager()->subscribeToDefaultPerms($this->isOp(), $this->parent !== null ? $this->parent : $this);
|
||||
|
||||
foreach($defaults as $perm){
|
||||
$name = $perm->getName();
|
||||
$this->permissions[$name] = new PermissionAttachmentInfo($this->parent, $name, null, true);
|
||||
Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent);
|
||||
$this->permissions[$name] = new PermissionAttachmentInfo($this->parent !== null ? $this->parent : $this, $name, null, true);
|
||||
Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent !== null ? $this->parent : $this);
|
||||
$this->calculateChildPermissions($perm->getChildren(), false, null);
|
||||
}
|
||||
|
||||
@ -186,11 +189,11 @@ class PermissibleBase implements Permissible{
|
||||
|
||||
public function clearPermissions(){
|
||||
foreach(array_keys($this->permissions) as $name){
|
||||
Server::getInstance()->getPluginManager()->unsubscribeFromPermission($name, $this->parent);
|
||||
Server::getInstance()->getPluginManager()->unsubscribeFromPermission($name, $this->parent !== null ? $this->parent : $this);
|
||||
}
|
||||
|
||||
Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(false, $this->parent);
|
||||
Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(true, $this->parent);
|
||||
Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(false, $this->parent !== null ? $this->parent : $this);
|
||||
Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(true, $this->parent !== null ? $this->parent : $this);
|
||||
|
||||
$this->permissions = [];
|
||||
}
|
||||
@ -204,8 +207,8 @@ class PermissibleBase implements Permissible{
|
||||
foreach($children as $name => $v){
|
||||
$perm = Server::getInstance()->getPluginManager()->getPermission($name);
|
||||
$value = ($v xor $invert);
|
||||
$this->permissions[$name] = new PermissionAttachmentInfo($this->parent, $name, $attachment, $value);
|
||||
Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent);
|
||||
$this->permissions[$name] = new PermissionAttachmentInfo($this->parent !== null ? $this->parent : $this, $name, $attachment, $value);
|
||||
Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent !== null ? $this->parent : $this);
|
||||
|
||||
if($perm instanceof Permission){
|
||||
$this->calculateChildPermissions($perm->getChildren(), !$value, $attachment);
|
||||
|
Reference in New Issue
Block a user