PlayerChatEvent: fixed crash when non-CommandSender permissibles subscribe to broadcast permission

doing such a thing doesn't make any sense, but the system allows it, so it has to be accounted for.
This commit is contained in:
Dylan K. Taylor 2019-12-01 21:44:13 +00:00
parent c4a8781b5c
commit ce27c03774

View File

@ -28,6 +28,7 @@ use pocketmine\event\Cancellable;
use pocketmine\permission\PermissionManager;
use pocketmine\Player;
use pocketmine\Server;
use function spl_object_id;
/**
* Called when a player chats something
@ -57,7 +58,11 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{
$this->format = $format;
if($recipients === null){
$this->recipients = PermissionManager::getInstance()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_USERS);
foreach(PermissionManager::getInstance()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_USERS) as $permissible){
if($permissible instanceof CommandSender){
$this->recipients[spl_object_id($permissible)] = $permissible;
}
}
}else{
$this->recipients = $recipients;
}