mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Moved SetTitlePacket usage to NetworkSession (#3186)
This commit is contained in:
parent
92700b2e18
commit
7276eda0e5
@ -64,6 +64,7 @@ use pocketmine\network\mcpe\protocol\ServerboundPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetTitlePacket;
|
||||
use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\network\mcpe\protocol\TransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\command\CommandData;
|
||||
@ -843,6 +844,30 @@ class NetworkSession{
|
||||
}
|
||||
}
|
||||
|
||||
public function onTitle(string $title) : void{
|
||||
$this->sendDataPacket(SetTitlePacket::title($title));
|
||||
}
|
||||
|
||||
public function onSubTitle(string $subtitle) : void{
|
||||
$this->sendDataPacket(SetTitlePacket::subtitle($subtitle));
|
||||
}
|
||||
|
||||
public function onActionBar(string $actionBar) : void{
|
||||
$this->sendDataPacket(SetTitlePacket::actionBarMessage($actionBar));
|
||||
}
|
||||
|
||||
public function onClearTitle() : void{
|
||||
$this->sendDataPacket(SetTitlePacket::clearTitle());
|
||||
}
|
||||
|
||||
public function onResetTitleOptions() : void{
|
||||
$this->sendDataPacket(SetTitlePacket::resetTitleOptions());
|
||||
}
|
||||
|
||||
public function onTitleDuration(int $fadeIn, int $stay, int $fadeOut) : void{
|
||||
$this->sendDataPacket(SetTitlePacket::setAnimationTimes($fadeIn, $stay, $fadeOut));
|
||||
}
|
||||
|
||||
public function tick() : bool{
|
||||
if($this->info === null){
|
||||
if(time() >= $this->connectTime + 10){
|
||||
|
@ -85,7 +85,6 @@ use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetTitlePacket;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\PlayerMetadataFlags;
|
||||
@ -1900,7 +1899,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
if($subtitle !== ""){
|
||||
$this->sendSubTitle($subtitle);
|
||||
}
|
||||
$this->networkSession->sendDataPacket(SetTitlePacket::title($title));
|
||||
$this->networkSession->onTitle($title);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1909,7 +1908,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
* @param string $subtitle
|
||||
*/
|
||||
public function sendSubTitle(string $subtitle) : void{
|
||||
$this->networkSession->sendDataPacket(SetTitlePacket::subtitle($subtitle));
|
||||
$this->networkSession->onSubTitle($subtitle);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1918,21 +1917,21 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
* @param string $message
|
||||
*/
|
||||
public function sendActionBarMessage(string $message) : void{
|
||||
$this->networkSession->sendDataPacket(SetTitlePacket::actionBarMessage($message));
|
||||
$this->networkSession->onActionBar($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the title from the client's screen.
|
||||
*/
|
||||
public function removeTitles(){
|
||||
$this->networkSession->sendDataPacket(SetTitlePacket::clearTitle());
|
||||
$this->networkSession->onClearTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the title duration settings to defaults and removes any existing titles.
|
||||
*/
|
||||
public function resetTitles(){
|
||||
$this->networkSession->sendDataPacket(SetTitlePacket::resetTitleOptions());
|
||||
$this->networkSession->onResetTitleOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1944,7 +1943,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
*/
|
||||
public function setTitleDuration(int $fadeIn, int $stay, int $fadeOut){
|
||||
if($fadeIn >= 0 and $stay >= 0 and $fadeOut >= 0){
|
||||
$this->networkSession->sendDataPacket(SetTitlePacket::setAnimationTimes($fadeIn, $stay, $fadeOut));
|
||||
$this->networkSession->onTitleDuration($fadeIn, $stay, $fadeOut);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user