From 932c489de153dbc1491f6f0e7f893f216ec834d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=3D=3FUTF-8=3Fq=3FFabian=3D20Fa=3DC3=3D9Fbender=3F=3D?= Date: Wed, 1 May 2019 18:52:03 +0100 Subject: [PATCH] Rename addTitle/addSubTitle/addActionBarMessage prefixes to "send", deprecated old variants closes #2896 these deprecated methods will be removed in 4.0. --- src/pocketmine/Player.php | 42 +++++++++++++++++-- src/pocketmine/Server.php | 2 +- .../command/defaults/TitleCommand.php | 6 +-- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 2997ce568..d2d9926b5 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -3259,7 +3259,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } /** - * Adds a title text to the user's screen, with an optional subtitle. + * @deprecated + * @see Player::sendTitle() * * @param string $title * @param string $subtitle @@ -3268,28 +3269,61 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * @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 c5911d8b8..c336caf34 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1872,7 +1872,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){