mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-20 10:00:31 +00:00
Removed Server->broadcast()
this method has an explicit dependency on permission subscriptions, which I plan to eradicate. The method's functionality can be replaced using Server->broadcastMessage() with a custom recipients array.
This commit is contained in:
parent
ecbc4e9433
commit
70b0d83258
@ -1090,7 +1090,12 @@ class Server{
|
|||||||
*/
|
*/
|
||||||
public function broadcastMessage($message, ?array $recipients = null) : int{
|
public function broadcastMessage($message, ?array $recipients = null) : int{
|
||||||
if(!is_array($recipients)){
|
if(!is_array($recipients)){
|
||||||
return $this->broadcast($message, self::BROADCAST_CHANNEL_USERS);
|
$recipients = [];
|
||||||
|
foreach(PermissionManager::getInstance()->getPermissionSubscriptions(self::BROADCAST_CHANNEL_USERS) as $permissible){
|
||||||
|
if($permissible instanceof CommandSender and $permissible->hasPermission(self::BROADCAST_CHANNEL_USERS)){
|
||||||
|
$recipients[spl_object_id($permissible)] = $permissible; // do not send messages directly, or some might be repeated
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($recipients as $recipient){
|
foreach($recipients as $recipient){
|
||||||
@ -1156,27 +1161,6 @@ class Server{
|
|||||||
return count($recipients);
|
return count($recipients);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param TranslationContainer|string $message
|
|
||||||
*/
|
|
||||||
public function broadcast($message, string $permissions) : int{
|
|
||||||
/** @var CommandSender[] $recipients */
|
|
||||||
$recipients = [];
|
|
||||||
foreach(explode(";", $permissions) as $permission){
|
|
||||||
foreach(PermissionManager::getInstance()->getPermissionSubscriptions($permission) as $permissible){
|
|
||||||
if($permissible instanceof CommandSender and $permissible->hasPermission($permission)){
|
|
||||||
$recipients[spl_object_id($permissible)] = $permissible; // do not send messages directly, or some might be repeated
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($recipients as $recipient){
|
|
||||||
$recipient->sendMessage($message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return count($recipients);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Player[] $players
|
* @param Player[] $players
|
||||||
* @param ClientboundPacket[] $packets
|
* @param ClientboundPacket[] $packets
|
||||||
|
Loading…
x
Reference in New Issue
Block a user