Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Use broadcast permission to broadcast tips and popups
Browse files Browse the repository at this point in the history
  • Loading branch information
msjyoo committed May 23, 2015
1 parent a0f8bc1 commit 76c27fc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/pocketmine/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,14 @@ public function broadcastMessage($message, $recipients = null){
*/
public function broadcastTip($tip, $recipients = null){
if(!is_array($recipients)){
return $this->broadcastTip($tip, $this->getOnlinePlayers());
/** @var Player[] $recipients */
$recipients = [];

foreach($this->pluginManager->getPermissionSubscriptions(self::BROADCAST_CHANNEL_USERS) as $permissible){
if($permissible instanceof Player and $permissible->hasPermission(self::BROADCAST_CHANNEL_USERS)){
$recipients[spl_object_hash($permissible)] = $permissible; // do not send messages directly, or some might be repeated
}
}
}

/** @var Player[] $recipients */
Expand All @@ -1809,7 +1816,14 @@ public function broadcastTip($tip, $recipients = null){
*/
public function broadcastPopup($popup, $recipients = null){
if(!is_array($recipients)){
return $this->broadcastPopup($popup, $this->getOnlinePlayers());
/** @var Player[] $recipients */
$recipients = [];

foreach($this->pluginManager->getPermissionSubscriptions(self::BROADCAST_CHANNEL_USERS) as $permissible){
if($permissible instanceof Player and $permissible->hasPermission(self::BROADCAST_CHANNEL_USERS)){
$recipients[spl_object_hash($permissible)] = $permissible; // do not send messages directly, or some might be repeated
}
}
}

/** @var Player[] $recipients */
Expand Down

0 comments on commit 76c27fc

Please sign in to comment.