PHP code example of xxarox / bossbar-api

1. Go to this page and download the library: Download xxarox/bossbar-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xxarox / bossbar-api example snippets


use xxAROX\BossbarAPI\{Bossbar,BossbarColor};

$bossBar = new Bossbar(
	"Space suits yell with faith!",
	1.0,
	/** @var BossbarColor */ BossbarColor::RED(),
	/** @var bool */ false,
	/** @var null|Vector3 */ $game->getMiddleVector3()
);
// add players
$bossBar->addAllPlayers();
$bossBar->addPlayer(Player::class);

// remove players
$bossBar->removeAllPlayers();
$bossBar->removePlayer(Player::class);

// check player
$bossBar->thout mystery, and we won’t handle a captain.")
	->setPercentage(0)
	->setColor(BossbarColor::BLUE())
;

use xxAROX\BossbarAPI\{Bossbar,BossbarColor};

$bossBar = new Bossbar(
	"bossbar.title.example",
	1.0,
	/** @var BossbarColor */ BossbarColor::RED(),
	/** @var bool */ false,
	/** @var null|Vector3 */ $game->getMiddleVector3()
);
// first add a translation handler of your choice
$bossBar->setTextHandler(fn (\pocketmine\player\Player $player, string $raw) => $player->getLanguage()->translate(new \pocketmine\lang\Translatable($raw)));

// add players
$bossBar->addAllPlayers();

// update title
$bossBar->setTitle("my.language.key");