Coder Social home page Coder Social logo

revanddev / apibossbar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from inxomnyaa/apibossbar

0.0 0.0 0.0 33 KB

A simple virion API for Minecraft Bossbars for PocketMine-MP

Home Page: https://poggit.pmmp.io/ci/thebigsmileXD/apibossbar/~

License: GNU General Public License v3.0

PHP 100.00%

apibossbar's Introduction

apibossbar

A simple api virion to create, send, modify and use Minecraft's boss mob indicator bars in Plugins for PocketMine-MP

Advantages

It is quite easy to use this API

  • It uses a single object
  • Fluent setters (use multiple functions in 1 line)
  • Cleaner code
  • Easier to understand
  • No worrying about the used entity id
  • 2 types of bars (BossBar is same for all players, DiverseBossBar can be modified per player)
  • No "API::function()" calls, just object methods
  • Changeable entity (Can be used for actual boss mobs i.e.)

Types

There are 2 types of boss bars.

  • BossBar: is used for shared data, so all registered players see the same bar.
  • DiverseBossBar: is used for unique data, their data can be changed per player. They can also be set in a batch for multiple players, and will use default values if no specific data is set for a player. The default data is set like on a shared BossBar

API & usage

A very basic example can be seen here: BossBarTest. For a more advanced example you could check out BossAnnouncement

Create a new boss bar

/** @var BossBar */
$bar = new BossBar();

Set the title and/or subtitle

$bar->setTitle(string $title = "");
$bar->setSubTitle(string $subTitle = "");

Set the fill percentage

// Half-filled
$bar->setPercentage(0.5);

Add and remove players

// Single
$bar->addPlayer(Player $player);// This will spawn the bar to the player
$bar->removePlayer(Player $player);
// Multiple
/** @var Player[] $players */
$bar->addPlayers(array $players);
$bar->removePlayers(array $players);
$bar->removeAllPlayers();

Hide and show bar

/** @var Player[] $players */
$bar->hideFrom(array $players);
$bar->showTo(array $players);

Get and set the entity the bar is assigned to

/** @var Entity|Player $entity */
$bar->getEntity();
$bar->setEntity(Entity $entity);
$bar->resetEntity();

Single line example

/** @var Player $player */
$player = Server::getInstance()->getPlayerByName("Steve");
/** @var BossBar */
$bar = (new BossBar())->setTitle("Hello world!")->setSubTitle("Foo Bar")->setPercentage(0.5)->addPlayer($player);

DiverseBossBar has some additional methods to set data per player:

Reset the data to its defaults

$bar->resetFor(Player $player);
$bar->resetForAll();

Set & get title for players

/** @var Player[] $players */
$bar->setTitleFor(array $players);
$bar->setSubTitleFor(array $players);
$bar->getTitleFor(Player $player);
$bar->getSubTitleFor(Player $player);
$bar->getFullTitleFor(Player $player);// Combined and encoded title & subtitle

Set percentage for players

/** @var Player[] $players */
$bar->setPercentageFor(array $players);
$bar->getPercentageFor(Player $player);

Disclaimer & Information

Coded and maintained by XenialDan

Feel free to open issues with suggestions and bug reports. Please leave as much information as possible to help speeding up the debugging of the issues.

This is a full rework of BossBarAPI. Plugins that used this virion should be upgraded to apibossbar ASAP

Colors and overlays do not work due to not being properly implemented in the client (They use data from the resource pack definitions file). #blamemojang for copy-paste leftovers from Minecraft: Java Edition

apibossbar's People

Contributors

inxomnyaa avatar poggit-bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.