diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 4af97a252..3d3b1743b 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1716,6 +1716,36 @@ class Server{ return count($recipients); } + /** + * @param string $title + * @param string $subtitle + * @param int $fadeIn Duration in ticks for fade-in. If -1 is given, client-sided defaults will be used. + * @param int $stay Duration in ticks to stay on screen for + * @param int $fadeOut Duration in ticks for fade-out. + * @param Player[]|null $recipients + * + * @return int + */ + public function broadcastTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1, $recipients = null){ + if(!is_array($recipients)){ + /** @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 */ + foreach($recipients as $recipient){ + $recipient->addTitle($title, $subtitle, $fadeIn, $stay, $fadeOut); + } + + return count($recipients); + } + /** * @param string $message * @param string $permissions