mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +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 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);
|
||||
|
||||
|
@ -93,7 +93,9 @@ class PermissionAttachment{
|
||||
* @param bool $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();
|
||||
}
|
||||
|
||||
|
@ -434,6 +434,9 @@ class PluginManager{
|
||||
public function unsubscribeFromPermission($permission, Permissible $permissible){
|
||||
if(isset($this->permSubs[$permission])){
|
||||
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