{"id":15127771,"url":"https://github.com/jasonw4331/scoreboardapi","last_synced_at":"2025-09-28T14:31:25.367Z","repository":{"id":55963241,"uuid":"153486588","full_name":"jasonw4331/ScoreboardAPI","owner":"jasonw4331","description":"A simple API for creating scoreboards on PocketMine-MP servers","archived":true,"fork":false,"pushed_at":"2020-12-04T04:56:37.000Z","size":76,"stargazers_count":17,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-09-27T02:05:28.519Z","etag":null,"topics":["php","pocketmine","pocketmine-mp"],"latest_commit_sha":null,"homepage":"https://discord.gg/R7kdetE","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jasonw4331.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-17T16:10:36.000Z","updated_at":"2023-01-28T09:59:52.000Z","dependencies_parsed_at":"2022-08-15T10:20:48.893Z","dependency_job_id":null,"html_url":"https://github.com/jasonw4331/ScoreboardAPI","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonw4331%2FScoreboardAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonw4331%2FScoreboardAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonw4331%2FScoreboardAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonw4331%2FScoreboardAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jasonw4331","download_url":"https://codeload.github.com/jasonw4331/ScoreboardAPI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234525643,"owners_count":18846939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","pocketmine","pocketmine-mp"],"created_at":"2024-09-26T02:05:25.333Z","updated_at":"2025-09-28T14:31:20.127Z","avatar_url":"https://github.com/jasonw4331.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ScoreboardAPI\n[![Discord](https://img.shields.io/badge/chat-on%20discord-7289da.svg)](https://discord.gg/tZQMhBQ)\n[![Poggit-Ci](https://poggit.pmmp.io/ci.shield/jasonwynn10/ScoreboardAPI/ScoreboardAPI)](https://poggit.pmmp.io/ci/jasonwynn10/ScoreboardAPI/ScoreboardAPI)\n[![Download count](https://poggit.pmmp.io/shield.dl.total/ScoreboardAPI)](https://poggit.pmmp.io/p/ScoreboardAPI)\n\n## Basic API\n#### Imports\nYou will want all of these classes imported where you are using ScoreboardAPI.\n```php\nuse jasonwynn10\\ScoreboardAPI\\Scoreboard;\nuse jasonwynn10\\ScoreboardAPI\\ScoreboardAPI;\nuse jasonwynn10\\ScoreboardAPI\\ScoreboardEntry;\n```\n\n#### Creating a scoreboard\nScoreboard instances can be created through the ScoreboardAPI class.\nThis method defaults to using the sidebar with scores in ascending order.\n```php\n/** @var PluginBase $this */\n$api = $this-\u003egetServer()-\u003egetPluginManager()-\u003egetPlugin(\"ScoreboardAPI\");\n$scoreboard = $api-\u003ecreateScoreboard(\"objective\", \"Scoreboard Title\"); // assumes sidebar in ascending order\n```\n\n#### Adding an entry\nScoreboards aren't just titles. They need something to fill their lines!\n\nEntries can be created and added to scoreboards through the Scoreboard instance.\n```php\n$line = 1; // line number\n$score = 1; // current score\n$type = ScoreboardEntry::TYPE_FAKE_PLAYER; // other types are TYPE_PLAYER and TYPE_ENTITY\n$identifier = \"line 1\"; // this is a string for fake players but must be an entity id for other types\n/** @var Scoreboard $scoreboard */\n$entry = $scoreboard-\u003ecreateEntry($line, $score, $type, $identifier);\n$scoreboard-\u003eaddEntry($entry);\n```\nOnce an entry as been added to the scoreboard, all scoreboard viewers will automatically be able to see it.\n\n#### Removing an Entry\nEntries can be removed from scoreboards through the Scoreboard instance.\n```php\n/** @var Scoreboard $scoreboard */\n$entry = $scoreboard-\u003ecreateEntry(1, 1, ScoreboardEntry::TYPE_FAKE_PLAYER, \"Line 1\");\n$scoreboard-\u003eaddEntry($entry); // entry added\n\n$scoreboard-\u003eremoveEntry($entry); // remove entry\n```\nOnce an entry as been removed from the scoreboard, all scoreboard viewers will automatically be able to see it.\n\n#### Updating an entry\nSo now you have your entries all on the board, but you need to change one.\n\nEntries can be updated through the Scoreboard instance.\n```php\n/** @var Scoreboard $scoreboard */\n$scoreboard-\u003eaddEntry($entry); // entry added\n$entry-\u003escore++; // update score\n$entry-\u003ecustomName = \"Line \".$entry-\u003escore; // update custom name\n$scoreboard-\u003eupdateEntry($entry); // update changed entry\n```\n\n#### Sending a scoreboard\nNow that you've prepared your scoreboard, it needs sent to the players!\n\nScoreboards can be sent through the ScoreboardAPI class.\n```php\n/** @var PluginBase $this */\n$api = $this-\u003egetServer()-\u003egetPluginManager()-\u003egetPlugin(\"ScoreboardAPI\");\n$scoreboard = $api-\u003ecreateScoreboard(\"objective\", \"Scoreboard Title\");\n\n$api-\u003esendScoreboard($scoreboard); // send scoreboard to everyone\n```\n\n#### Deleting a scoreboard\nLet's say you don't want the scoreboard to show to people anymore.\n\nScoreboards can be removed through the ScoreboardAPI class.\n```php\n/** @var PluginBase $this */\n$api = $this-\u003egetServer()-\u003egetPluginManager()-\u003egetPlugin(\"ScoreboardAPI\");\n$scoreboard = $api-\u003ecreateScoreboard(\"objective\", \"Scoreboard Title\");\n$api-\u003esendScoreboard($scoreboard); // scoreboard sent to everyone\n\n$api-\u003eremoveScoreboard($scoreboard); // remove scoreboard from everyone\n```\n\n## Advanced API\n#### Alternate Scoreboard Creation\nScoreboard 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.\n```php\n/** @var PluginBase $this */\n$api = $this-\u003egetServer()-\u003egetPluginManager()-\u003egetPlugin(\"ScoreboardAPI\");\n$scoreboard = $api-\u003ecreateScoreboard(\"objective\", \"Scoreboard Title\", Scoreboard::SLOT_LIST, Scoreboard::SORT_DESCENDING); // scoreboard is in list slot in descending order\n```\n\n#### Scoreboard Viewers\nIn `ScoreboardAPI::sendScoreboard()`, the second parameter can be set for specific scoreboard viewers to be added.\n```php\n/** @var PluginBase $this */\n$api = $this-\u003egetServer()-\u003egetPluginManager()-\u003egetPlugin(\"ScoreboardAPI\");\n$scoreboard = $api-\u003ecreateScoreboard(\"objective\", \"Scoreboard Title\"); //create scoreboard\n\n/** @var Player $player */\n$api-\u003esendScoreboard($scoreboard, [$player]); // scoreboard sent to player\n```\n\nLike sending, the second parameter in `ScoreboardAPI::removeScoreboard()` can be set for specific scoreboard viewers to be removed.\n```php\n/** @var PluginBase $this */\n$api = $this-\u003egetServer()-\u003egetPluginManager()-\u003egetPlugin(\"ScoreboardAPI\");\n$scoreboard = $api-\u003ecreateScoreboard(\"objective\", \"Scoreboard Title\");\n/** @var Player $player */\n$api-\u003esendScoreboard($scoreboard); // scoreboard sent to everyone\n\n$api-\u003eremoveScoreboard($scoreboard, [$player]); // scoreboard removed from player\n```\n#### Entry Viewers\nEntry viewers can be set when adding the entry to the scoreboard via the second parameter of `Scoreboard::addEntry()`\n```php\n$line = 1; // line number\n$score = 1; // current score\n$type = ScoreboardEntry::TYPE_FAKE_PLAYER; // other types are TYPE_PLAYER and TYPE_ENTITY\n$identifier = \"line 1\"; // this is a string for fake players but must be an entity id for other types\n/** @var Scoreboard $scoreboard */\n$entry = $scoreboard-\u003ecreateEntry($line, $score, $type, $identifier);\n/** @var Player $player */\n$scoreboard-\u003eaddEntry($entry, [$player]); // add entry to scoreboard for player\n```\n\nPlayers can be specified for removing the entry via the second parameter of `Scoreboard::removeEntry()`\n```php\n$line = 1; // line number\n$score = 1; // current score\n$type = ScoreboardEntry::TYPE_FAKE_PLAYER; // other types are TYPE_PLAYER and TYPE_ENTITY\n$identifier = \"line 1\"; // this is a string for fake players but must be an entity id for other types\n/** @var Scoreboard $scoreboard */\n$entry = $scoreboard-\u003ecreateEntry($line, $score, $type, $identifier);\n/** @var Player $player */\n$scoreboard-\u003eremoveEntry($entry, [$player]); // remove entry only for player\n```\n\nUpdating entries works the similar to adding and removing them by use of the second parameter in `Scoreboard::updateEntry()`\n```php\n/** @var Scoreboard $scoreboard */\n$scoreboard-\u003eaddEntry($entry); // add entry\n$entry-\u003escore++; // update score\n$entry-\u003ecustomName = \"Line \".$entry-\u003escore; // update custom name\n/** @var Player $player */\n$scoreboard-\u003eupdateEntry($entry, [$player]); // update changed entry for player\n```\n\nOnce an entry as been added or removed, all specified viewers will be able to see the changes immediately.\n#### Scoreboard Padding\nPadding 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.\n```php\n/** @var Scoreboard $scoreboard */\n$scoreboard-\u003epadEntries();\n```\n#### Entry Padding\nEntry 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.\n```php\n/** @var ScoreboardEntry $entry */\n$entry-\u003epad();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonw4331%2Fscoreboardapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasonw4331%2Fscoreboardapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonw4331%2Fscoreboardapi/lists"}