mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 04:17:48 +00:00
Added API method Server->broadcastTitle() (#932)
This commit is contained in:
parent
76ab3d4288
commit
ca6826898b
@ -1716,6 +1716,36 @@ class Server{
|
|||||||
return count($recipients);
|
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 $message
|
||||||
* @param string $permissions
|
* @param string $permissions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user