Introduce Player::sendToastNotification() (#5102)

This commit is contained in:
famima65536 2022-09-23 19:37:08 +09:00 committed by GitHub
parent 7d29ac8293
commit e4fc523251
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -88,6 +88,7 @@ use pocketmine\network\mcpe\protocol\SetTimePacket;
use pocketmine\network\mcpe\protocol\SetTitlePacket;
use pocketmine\network\mcpe\protocol\TakeItemActorPacket;
use pocketmine\network\mcpe\protocol\TextPacket;
use pocketmine\network\mcpe\protocol\ToastRequestPacket;
use pocketmine\network\mcpe\protocol\TransferPacket;
use pocketmine\network\mcpe\protocol\types\BlockPosition;
use pocketmine\network\mcpe\protocol\types\command\CommandData;
@ -1100,6 +1101,10 @@ class NetworkSession{
$this->sendDataPacket(EmotePacket::create($from->getId(), $emoteId, EmotePacket::FLAG_SERVER));
}
public function onToastNotification(string $title, string $body) : void{
$this->sendDataPacket(ToastRequestPacket::create($title, $body));
}
public function tick() : void{
if($this->info === null){
if(time() >= $this->connectTime + 10){

View File

@ -1986,6 +1986,13 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$this->getNetworkSession()->onTip($message);
}
/**
* Sends a toast message to the player, or queue to send it if a toast message is already shown.
*/
public function sendToastNotification(string $title, string $body) : void{
$this->getNetworkSession()->onToastNotification($title, $body);
}
/**
* Sends a Form to the player, or queue to send it if a form is already open.
*