Merge branch 'next-minor'

This commit is contained in:
Dylan K. Taylor 2019-05-01 18:55:49 +01:00
commit 293311569d
3 changed files with 42 additions and 8 deletions

View File

@ -2257,7 +2257,8 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
} }
/** /**
* Adds a title text to the user's screen, with an optional subtitle. * @deprecated
* @see Player::sendTitle()
* *
* @param string $title * @param string $title
* @param string $subtitle * @param string $subtitle
@ -2266,28 +2267,61 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
* @param int $fadeOut Duration in ticks for fade-out. * @param int $fadeOut Duration in ticks for fade-out.
*/ */
public function addTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1){ public function addTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1){
$this->sendTitle($title, $subtitle, $fadeIn, $stay, $fadeOut);
}
/**
* Adds a title text to the user's screen, with an optional subtitle.
*
* @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.
*/
public function sendTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1) : void{
$this->setTitleDuration($fadeIn, $stay, $fadeOut); $this->setTitleDuration($fadeIn, $stay, $fadeOut);
if($subtitle !== ""){ if($subtitle !== ""){
$this->addSubTitle($subtitle); $this->sendSubTitle($subtitle);
} }
$this->sendTitleText($title, SetTitlePacket::TYPE_SET_TITLE); $this->sendTitleText($title, SetTitlePacket::TYPE_SET_TITLE);
} }
/**
* @deprecated
* @see Player::sendSubTitle()
*
* @param string $subtitle
*/
public function addSubTitle(string $subtitle){
$this->sendSubTitle($subtitle);
}
/** /**
* Sets the subtitle message, without sending a title. * Sets the subtitle message, without sending a title.
* *
* @param string $subtitle * @param string $subtitle
*/ */
public function addSubTitle(string $subtitle){ public function sendSubTitle(string $subtitle) : void{
$this->sendTitleText($subtitle, SetTitlePacket::TYPE_SET_SUBTITLE); $this->sendTitleText($subtitle, SetTitlePacket::TYPE_SET_SUBTITLE);
} }
/**
* @deprecated
* @see Player::sendActionBarMessage()
*
* @param string $message
*/
public function addActionBarMessage(string $message){
$this->sendActionBarMessage($message);
}
/** /**
* Adds small text to the user's screen. * Adds small text to the user's screen.
* *
* @param string $message * @param string $message
*/ */
public function addActionBarMessage(string $message){ public function sendActionBarMessage(string $message) : void{
$this->sendTitleText($message, SetTitlePacket::TYPE_SET_ACTIONBAR_MESSAGE); $this->sendTitleText($message, SetTitlePacket::TYPE_SET_ACTIONBAR_MESSAGE);
} }

View File

@ -1421,7 +1421,7 @@ class Server{
/** @var Player[] $recipients */ /** @var Player[] $recipients */
foreach($recipients as $recipient){ foreach($recipients as $recipient){
$recipient->addTitle($title, $subtitle, $fadeIn, $stay, $fadeOut); $recipient->sendTitle($title, $subtitle, $fadeIn, $stay, $fadeOut);
} }
return count($recipients); return count($recipients);

View File

@ -68,21 +68,21 @@ class TitleCommand extends VanillaCommand{
throw new InvalidCommandSyntaxException(); throw new InvalidCommandSyntaxException();
} }
$player->addTitle(implode(" ", array_slice($args, 2))); $player->sendTitle(implode(" ", array_slice($args, 2)));
break; break;
case "subtitle": case "subtitle":
if(count($args) < 3){ if(count($args) < 3){
throw new InvalidCommandSyntaxException(); throw new InvalidCommandSyntaxException();
} }
$player->addSubTitle(implode(" ", array_slice($args, 2))); $player->sendSubTitle(implode(" ", array_slice($args, 2)));
break; break;
case "actionbar": case "actionbar":
if(count($args) < 3){ if(count($args) < 3){
throw new InvalidCommandSyntaxException(); throw new InvalidCommandSyntaxException();
} }
$player->addActionBarMessage(implode(" ", array_slice($args, 2))); $player->sendActionBarMessage(implode(" ", array_slice($args, 2)));
break; break;
case "times": case "times":
if(count($args) < 5){ if(count($args) < 5){