mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 04:17:48 +00:00
Fixed Permissible::setPermission() not using the correct order on replacement
This commit is contained in:
parent
fba12c6ddf
commit
4624dfb472
@ -194,10 +194,10 @@ class PermissibleBase implements Permissible{
|
|||||||
* @param bool $invert
|
* @param bool $invert
|
||||||
* @param PermissionAttachment $attachment
|
* @param PermissionAttachment $attachment
|
||||||
*/
|
*/
|
||||||
public function calculateChildPermissions(array $children, $invert, $attachment){
|
private function calculateChildPermissions(array $children, $invert, $attachment){
|
||||||
foreach(array_keys($children) as $name){
|
foreach($children as $name => $v){
|
||||||
$perm = Server::getInstance()->getPluginManager()->getPermission($name);
|
$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);
|
$this->permissions[$name] = new PermissionAttachmentInfo($this->parent, $name, $attachment, $value);
|
||||||
Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent);
|
Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent);
|
||||||
|
|
||||||
|
@ -93,7 +93,9 @@ class PermissionAttachment{
|
|||||||
* @param bool $value
|
* @param bool $value
|
||||||
*/
|
*/
|
||||||
public function setPermission($name, $value){
|
public function setPermission($name, $value){
|
||||||
$this->permissions[$name instanceof Permission ? $name->getName() : $name] = $value;
|
$name = $name instanceof Permission ? $name->getName() : $name;
|
||||||
|
unset($this->permissions[$name]); //Fixes children getting overwritten
|
||||||
|
$this->permissions[$name] = $value;
|
||||||
$this->permissible->recalculatePermissions();
|
$this->permissible->recalculatePermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,6 +434,9 @@ class PluginManager{
|
|||||||
public function unsubscribeFromPermission($permission, Permissible $permissible){
|
public function unsubscribeFromPermission($permission, Permissible $permissible){
|
||||||
if(isset($this->permSubs[$permission])){
|
if(isset($this->permSubs[$permission])){
|
||||||
unset($this->permSubs[$permission][spl_object_hash($permissible)]);
|
unset($this->permSubs[$permission][spl_object_hash($permissible)]);
|
||||||
|
if(count($this->permSubs[$permission]) === 0){
|
||||||
|
unset($this->permSubs[$permission]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user