You must use a custom API for this. PocketEssential have created an API, which you can find here: https://github.com/PocketEssential/BossBarAPI PHP: // First you"ll need thisuse PocketEssential\BossBarAPI\BossBarAPI;// You can also do:$BossBarAPI = BossBarAPI::getInstance(); Sending bossbar PHP: $message = "This is a BossBar message";$BossBarAPI->setBarMessage($message);/* Player should an instance of a PLAYER, Just foreach loop all the online players; etc */$BossBarAPI->sendBossBar($player);
It is possible to send packets, but I think he was trying to give OP a faster way. For anyone that wanted to know how to do this manually and create an API themself, here's how. Spoiler: Code to create the BossBar PHP: use pocketmine\item\Item;use pocketmine\network\protocol\AddPlayerPacket;use sys\jordan\utils\BossEventPacket;use pocketmine\network\protocol\MovePlayerPacket;use pocketmine\network\protocol\SetEntityDataPacket;use pocketmine\Player;use pocketmine\network\protocol\RemoveEntityPacket;use pocketmine\Server;use pocketmine\network\protocol\AddEntityPacket;use pocketmine\entity\Entity;use pocketmine\utils\UUID;class BossBar { private $plugin; public function __construct(Main $plugin){ $this->plugin = $plugin; } public function addBar(array $players = null){ if(empty($players)){ $players = $this->plugin->getPlayers(); } $eid = Entity::$entityCount++; $aepkt = new AddEntityPacket(); $aepkt->metadata = [Entity::DATA_LEAD_HOLDER => [Entity::DATA_TYPE_LONG, -1], Entity::DATA_FLAG_SILENT => [Entity::DATA_TYPE_BYTE, 1], Entity::DATA_SCALE => [Entity::DATA_TYPE_FLOAT, 0], Entity::DATA_BOUNDING_BOX_WIDTH => [Entity::DATA_TYPE_FLOAT, 0], Entity::DATA_BOUNDING_BOX_HEIGHT => [Entity::DATA_TYPE_FLOAT, 0]]; $aepkt->eid = Entity::$entityCount++; $aepkt->type = 52; $aepkt->yaw = 0; $aepkt->pitch = 0; foreach($players as $player){ $ppkt = clone $aepkt; $ppkt->x = $player->x; $ppkt->y = $player->y; $ppkt->z = $player->z; $player->dataPacket($ppkt); } $pk = new BossEventPacket(); $pk->state = 0; $pk->eid = Entity::$entityCount++; Server::getInstance()->broadcastPacket($players, $pk); return $eid; } public function setTitle(int $eid, string $string){ $players = $this->plugin->getServer()->getOnlinePlayers(); $pk = new SetEntityDataPacket(); $pk->metadata = [Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING, $string]]; $pk->eid = $eid; Server::getInstance()->broadcastPacket($players, $pk); $pkt = new BossEventPacket(); $pkt->eid = $eid; $pkt->state = 500; Server::getInstance()->broadcastPacket($players, $pkt); }}// You should probably use a task also. I will post this in the resources forum later.[/SPOILER]
But nobody else can use this method, because they don't have a BossEventPacket class. Also, your class paths aren't compatible with the current master branch of PMMP.
I really should've thought about that. Silly me, editing now and I will include BossEventPacket. Why isn't it compatible though?
There were some changes in PMMP that involves packets. The correct path for AddPlayerPacket, for example, would be: pocketmine\network\mcpe\protocol\AddPlayerPacket.
I assume it was because the former was a mess. This way network classes can be separated, since there are network classes for mcpe protocol, and for the raklib/etc. stuff. It's neater now, but there may be other reasons for the change I don't know about.