Implemented a better method for detecting permission recalculation

this allows anyone to listen to permissions being recalculated, which is useful for stuff like broadcast channel subscriptions.
This commit is contained in:
Dylan K. Taylor
2020-12-01 18:23:42 +00:00
parent c20893aa4b
commit 8fb74258f4
6 changed files with 68 additions and 44 deletions

View File

@@ -250,6 +250,16 @@ class NetworkSession{
$effectManager->getEffectAddHooks()->remove($effectAddHook);
$effectManager->getEffectRemoveHooks()->remove($effectRemoveHook);
});
$permissionHooks = $this->player->getPermissionRecalculationCallbacks();
$permissionHooks->add($permHook = function() : void{
$this->logger->debug("Syncing available commands and adventure settings due to permission recalculation");
$this->syncAdventureSettings($this->player);
$this->syncAvailableCommands();
});
$this->disposeHooks->add(static function() use ($permissionHooks, $permHook) : void{
$permissionHooks->remove($permHook);
});
}
public function getPlayer() : ?Player{