mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-19 04:15:04 +00:00
Command: validate permissions, require permission registration in advance of commands using them
this fixes #3200. This causes permissions to be registered before plugin load, which changes some behaviour, but after discussions on #internals-dev we couldn't see any reason to keep the behaviour the way it was, and several reasons to change it to be something like this.
This commit is contained in:
@@ -99,6 +99,13 @@ abstract class Command{
|
||||
}
|
||||
|
||||
public function setPermission(?string $permission) : void{
|
||||
if($permission !== null){
|
||||
foreach(explode(";", $permission) as $perm){
|
||||
if(PermissionManager::getInstance()->getPermission($perm) === null){
|
||||
throw new \InvalidArgumentException("Cannot use non-existing permission \"$perm\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->permission = $permission;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user