diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 942329b30..f5021ac58 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -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 $subtitle @@ -2266,28 +2267,61 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, * @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){ + $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); if($subtitle !== ""){ - $this->addSubTitle($subtitle); + $this->sendSubTitle($subtitle); } $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. * * @param string $subtitle */ - public function addSubTitle(string $subtitle){ + public function sendSubTitle(string $subtitle) : void{ $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. * * @param string $message */ - public function addActionBarMessage(string $message){ + public function sendActionBarMessage(string $message) : void{ $this->sendTitleText($message, SetTitlePacket::TYPE_SET_ACTIONBAR_MESSAGE); } diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index d042f4b1f..ee6885b8b 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1421,7 +1421,7 @@ class Server{ /** @var Player[] $recipients */ foreach($recipients as $recipient){ - $recipient->addTitle($title, $subtitle, $fadeIn, $stay, $fadeOut); + $recipient->sendTitle($title, $subtitle, $fadeIn, $stay, $fadeOut); } return count($recipients); diff --git a/src/pocketmine/command/defaults/TitleCommand.php b/src/pocketmine/command/defaults/TitleCommand.php index 667eeee08..030888912 100644 --- a/src/pocketmine/command/defaults/TitleCommand.php +++ b/src/pocketmine/command/defaults/TitleCommand.php @@ -68,21 +68,21 @@ class TitleCommand extends VanillaCommand{ throw new InvalidCommandSyntaxException(); } - $player->addTitle(implode(" ", array_slice($args, 2))); + $player->sendTitle(implode(" ", array_slice($args, 2))); break; case "subtitle": if(count($args) < 3){ throw new InvalidCommandSyntaxException(); } - $player->addSubTitle(implode(" ", array_slice($args, 2))); + $player->sendSubTitle(implode(" ", array_slice($args, 2))); break; case "actionbar": if(count($args) < 3){ throw new InvalidCommandSyntaxException(); } - $player->addActionBarMessage(implode(" ", array_slice($args, 2))); + $player->sendActionBarMessage(implode(" ", array_slice($args, 2))); break; case "times": if(count($args) < 5){