All Projects → jasonwynn10 → ScoreboardAPI

jasonwynn10 / ScoreboardAPI

Licence: GPL-3.0 license
A simple API for creating scoreboards on PocketMine-MP servers

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to ScoreboardAPI

MysteryBox
Crate implemention for PocketMine-MP (PMMP)
Stars: ✭ 19 (+18.75%)
Mutual labels:  pocketmine, pocketmine-mp
VirionTools
A handy plugin for developers who wish to compile and inject virions without using Poggit.
Stars: ✭ 17 (+6.25%)
Mutual labels:  pocketmine, pocketmine-mp
BuilderTools
🪓 Powerful World Editor plugin for PocketMine servers
Stars: ✭ 74 (+362.5%)
Mutual labels:  pocketmine, pocketmine-mp
PiggyAuth
Safe & feature-rich auth plugin. Project has been discontinued
Stars: ✭ 33 (+106.25%)
Mutual labels:  pocketmine, pocketmine-mp
BlockSniper
An advanced (brush) world editing plugin for PocketMine-MP
Stars: ✭ 77 (+381.25%)
Mutual labels:  pocketmine, pocketmine-mp
CommandShop
Players have to pay items or money to use specific commands! A PocketMine plugin.
Stars: ✭ 32 (+100%)
Mutual labels:  pocketmine, pocketmine-mp
CosmeticMenu
Fun and Easy-to-Use Pocketmine Cosmetics plugin. (Gadgets, Particles, Trails, etc)
Stars: ✭ 22 (+37.5%)
Mutual labels:  pocketmine, pocketmine-mp
SAC
An AntiCheat software for PockeMine-MP made to detect unfair gamplay advantages.
Stars: ✭ 52 (+225%)
Mutual labels:  pocketmine, pocketmine-mp
Pathfinding
A pmmp virion (library) for pathfinding using A*
Stars: ✭ 36 (+125%)
Mutual labels:  pocketmine, pocketmine-mp
MyPlot
Plot and protection plugin for PocketMine-MP
Stars: ✭ 101 (+531.25%)
Mutual labels:  pocketmine, pocketmine-mp
libform
It is a virion library that can handle various forms easily.
Stars: ✭ 12 (-25%)
Mutual labels:  pocketmine, pocketmine-mp
InvSee
A PocketMine-MP plugin that lets you view and modify offline and online players' inventories in real-time!
Stars: ✭ 19 (+18.75%)
Mutual labels:  pocketmine, pocketmine-mp
RedstoneCircuit
This is the PocketMine plugin that implements the Redstone circuit.
Stars: ✭ 81 (+406.25%)
Mutual labels:  pocketmine, pocketmine-mp
PM-Beacons
Vanilla Beacons for PocketMine Servers
Stars: ✭ 20 (+25%)
Mutual labels:  pocketmine, pocketmine-mp
Other-Plugins
A collection of all the plugins which I used to work on but no longer maintain
Stars: ✭ 26 (+62.5%)
Mutual labels:  pocketmine, pocketmine-mp
FormAPI-PMMP
Create a Form for Minecraft Bedrock in PocketMine-MP
Stars: ✭ 14 (-12.5%)
Mutual labels:  pocketmine, pocketmine-mp
IslandArchitect
An plugin to create custom sky island generators for the SkyBlock plugin
Stars: ✭ 12 (-25%)
Mutual labels:  pocketmine, pocketmine-mp
EggWars
EggWars minigame for PocketMine
Stars: ✭ 32 (+100%)
Mutual labels:  pocketmine, pocketmine-mp
AdvanceDeaths
A plugin to customize the death messages!
Stars: ✭ 16 (+0%)
Mutual labels:  pocketmine, pocketmine-mp
Emotes
This plugin allows players to use their favorite emotes on the server!
Stars: ✭ 15 (-6.25%)
Mutual labels:  pocketmine, pocketmine-mp

ScoreboardAPI

Discord Poggit-Ci Download count

Basic API

Imports

You will want all of these classes imported where you are using ScoreboardAPI.

use jasonwynn10\ScoreboardAPI\Scoreboard;
use jasonwynn10\ScoreboardAPI\ScoreboardAPI;
use jasonwynn10\ScoreboardAPI\ScoreboardEntry;

Creating a scoreboard

Scoreboard instances can be created through the ScoreboardAPI class. This method defaults to using the sidebar with scores in ascending order.

/** @var PluginBase $this */
$api = $this->getServer()->getPluginManager()->getPlugin("ScoreboardAPI");
$scoreboard = $api->createScoreboard("objective", "Scoreboard Title"); // assumes sidebar in ascending order

Adding an entry

Scoreboards aren't just titles. They need something to fill their lines!

Entries can be created and added to scoreboards through the Scoreboard instance.

$line = 1; // line number
$score = 1; // current score
$type = ScoreboardEntry::TYPE_FAKE_PLAYER; // other types are TYPE_PLAYER and TYPE_ENTITY
$identifier = "line 1"; // this is a string for fake players but must be an entity id for other types
/** @var Scoreboard $scoreboard */
$entry = $scoreboard->createEntry($line, $score, $type, $identifier);
$scoreboard->addEntry($entry);

Once an entry as been added to the scoreboard, all scoreboard viewers will automatically be able to see it.

Removing an Entry

Entries can be removed from scoreboards through the Scoreboard instance.

/** @var Scoreboard $scoreboard */
$entry = $scoreboard->createEntry(1, 1, ScoreboardEntry::TYPE_FAKE_PLAYER, "Line 1");
$scoreboard->addEntry($entry); // entry added

$scoreboard->removeEntry($entry); // remove entry

Once an entry as been removed from the scoreboard, all scoreboard viewers will automatically be able to see it.

Updating an entry

So now you have your entries all on the board, but you need to change one.

Entries can be updated through the Scoreboard instance.

/** @var Scoreboard $scoreboard */
$scoreboard->addEntry($entry); // entry added
$entry->score++; // update score
$entry->customName = "Line ".$entry->score; // update custom name
$scoreboard->updateEntry($entry); // update changed entry

Sending a scoreboard

Now that you've prepared your scoreboard, it needs sent to the players!

Scoreboards can be sent through the ScoreboardAPI class.

/** @var PluginBase $this */
$api = $this->getServer()->getPluginManager()->getPlugin("ScoreboardAPI");
$scoreboard = $api->createScoreboard("objective", "Scoreboard Title");

$api->sendScoreboard($scoreboard); // send scoreboard to everyone

Deleting a scoreboard

Let's say you don't want the scoreboard to show to people anymore.

Scoreboards can be removed through the ScoreboardAPI class.

/** @var PluginBase $this */
$api = $this->getServer()->getPluginManager()->getPlugin("ScoreboardAPI");
$scoreboard = $api->createScoreboard("objective", "Scoreboard Title");
$api->sendScoreboard($scoreboard); // scoreboard sent to everyone

$api->removeScoreboard($scoreboard); // remove scoreboard from everyone

Advanced API

Alternate Scoreboard Creation

Scoreboard instances can be created through the ScoreboardAPI class. This method defaults to using the sidebar with scores in ascending order, but can be changed to use either the LIST or BELOWNAME slot in descending order.

/** @var PluginBase $this */
$api = $this->getServer()->getPluginManager()->getPlugin("ScoreboardAPI");
$scoreboard = $api->createScoreboard("objective", "Scoreboard Title", Scoreboard::SLOT_LIST, Scoreboard::SORT_DESCENDING); // scoreboard is in list slot in descending order

Scoreboard Viewers

In ScoreboardAPI::sendScoreboard(), the second parameter can be set for specific scoreboard viewers to be added.

/** @var PluginBase $this */
$api = $this->getServer()->getPluginManager()->getPlugin("ScoreboardAPI");
$scoreboard = $api->createScoreboard("objective", "Scoreboard Title"); //create scoreboard

/** @var Player $player */
$api->sendScoreboard($scoreboard, [$player]); // scoreboard sent to player

Like sending, the second parameter in ScoreboardAPI::removeScoreboard() can be set for specific scoreboard viewers to be removed.

/** @var PluginBase $this */
$api = $this->getServer()->getPluginManager()->getPlugin("ScoreboardAPI");
$scoreboard = $api->createScoreboard("objective", "Scoreboard Title");
/** @var Player $player */
$api->sendScoreboard($scoreboard); // scoreboard sent to everyone

$api->removeScoreboard($scoreboard, [$player]); // scoreboard removed from player

Entry Viewers

Entry viewers can be set when adding the entry to the scoreboard via the second parameter of Scoreboard::addEntry()

$line = 1; // line number
$score = 1; // current score
$type = ScoreboardEntry::TYPE_FAKE_PLAYER; // other types are TYPE_PLAYER and TYPE_ENTITY
$identifier = "line 1"; // this is a string for fake players but must be an entity id for other types
/** @var Scoreboard $scoreboard */
$entry = $scoreboard->createEntry($line, $score, $type, $identifier);
/** @var Player $player */
$scoreboard->addEntry($entry, [$player]); // add entry to scoreboard for player

Players can be specified for removing the entry via the second parameter of Scoreboard::removeEntry()

$line = 1; // line number
$score = 1; // current score
$type = ScoreboardEntry::TYPE_FAKE_PLAYER; // other types are TYPE_PLAYER and TYPE_ENTITY
$identifier = "line 1"; // this is a string for fake players but must be an entity id for other types
/** @var Scoreboard $scoreboard */
$entry = $scoreboard->createEntry($line, $score, $type, $identifier);
/** @var Player $player */
$scoreboard->removeEntry($entry, [$player]); // remove entry only for player

Updating entries works the similar to adding and removing them by use of the second parameter in Scoreboard::updateEntry()

/** @var Scoreboard $scoreboard */
$scoreboard->addEntry($entry); // add entry
$entry->score++; // update score
$entry->customName = "Line ".$entry->score; // update custom name
/** @var Player $player */
$scoreboard->updateEntry($entry, [$player]); // update changed entry for player

Once an entry as been added or removed, all specified viewers will be able to see the changes immediately.

Scoreboard Padding

Padding the scoreboard will offset the text of each entry from the score with the most digits. Padding does not affect entries which use entity ids.

/** @var Scoreboard $scoreboard */
$scoreboard->padEntries();

Entry Padding

Entry padding can only be done with Fake Player types. Padding offsets the text from the score by the score with the most digits in the scoreboard.

/** @var ScoreboardEntry $entry */
$entry->pad();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].