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:
PEMapModder 2014-06-17 22:14:15 +08:00
parent 3bd33a129f
commit f202c9902a

View File

@ -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