mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
Multiple permissions checked in Server::getInstance()
This is done like the one in `Command::testPermissionSilent()`, where permissions are connected via semicolons (`;`) and they are checked with `OR`, where the player must have at least one permission to read.
This commit is contained in:
parent
3bd33a129f
commit
f202c9902a
@ -1476,21 +1476,24 @@ class Server{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param string $permission
|
* @param string $permissions
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function broadcast($message, $permission){
|
public function broadcast($message, $permissions){
|
||||||
$count = 0;
|
$recipients = [];
|
||||||
foreach($this->pluginManager->getPermissionSubscriptions($permission) as $permissible){
|
foreach(explode(";", $permissions) as $permission){
|
||||||
if($permissible instanceof CommandSender and $permissible->hasPermission($permission)){
|
foreach($this->pluginManager->getPermissionSubscriptions($permission) as $permissible){
|
||||||
$permissible->sendMessage($message);
|
if($permissible instanceof CommandSender and $permissible->hasPermission($permission)){
|
||||||
++$count;
|
$recipients[spl_object_hash($permissible)] = $permissible; // do not send messages directly, or some might be repeated
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach($recipients as $recipient){
|
||||||
return $count;
|
$recipient->sendMessage($message);
|
||||||
}
|
}
|
||||||
|
return count($recipients);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts a Minecraft packet to a list of players
|
* Broadcasts a Minecraft packet to a list of players
|
||||||
|
Loading…
x
Reference in New Issue
Block a user