Added title command and API for resetting title duration

This commit is contained in:
TheDiamondYT1
2017-04-27 16:38:51 +01:00
committed by Dylan K. Taylor
parent 84ec944b6b
commit 653b6b55a9
4 changed files with 125 additions and 2 deletions

View File

@ -3439,11 +3439,20 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
public function addTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1){
$this->setTitleDuration($fadeIn, $stay, $fadeOut);
if($subtitle !== ""){
$this->sendTitleText($subtitle, SetTitlePacket::TYPE_SET_SUBTITLE);
$this->addSubTitle($subtitle);
}
$this->sendTitleText($title, SetTitlePacket::TYPE_SET_TITLE);
}
/**
* Sets the subtitle message, without sending a title.
*
* @param string $subtitle
*/
public function addSubTitle(string $subtitle){
$this->sendTitleText($subtitle, SetTitlePacket::TYPE_SET_SUBTITLE);
}
/**
* Adds small text to the user's screen.
*
@ -3462,6 +3471,15 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->dataPacket($pk);
}
/**
* Resets the title duration settings.
*/
public function resetTitles(){
$pk = new SetTitlePacket();
$pk->type = SetTitlePacket::TYPE_RESET_TITLE;
$this->dataPacket($pk);
}
/**
* Sets the title duration.
*