{"id":16013421,"url":"https://github.com/sof3/chooseplayer","last_synced_at":"2025-08-01T08:34:07.622Z","repository":{"id":54404482,"uuid":"522234979","full_name":"SOF3/ChoosePlayer","owner":"SOF3","description":"API plugin to open a dialog for choosing another player.","archived":false,"fork":false,"pushed_at":"2023-04-22T07:52:14.000Z","size":764,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T10:01:35.218Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SOF3.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-07T14:27:02.000Z","updated_at":"2023-04-08T00:50:51.000Z","dependencies_parsed_at":"2024-10-27T16:13:42.505Z","dependency_job_id":"7591c8fd-4ac8-4fe7-bb53-ac765fbd0ffd","html_url":"https://github.com/SOF3/ChoosePlayer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SOF3/ChoosePlayer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2FChoosePlayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2FChoosePlayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2FChoosePlayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2FChoosePlayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SOF3","download_url":"https://codeload.github.com/SOF3/ChoosePlayer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2FChoosePlayer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268192592,"owners_count":24210541,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-08T14:41:13.407Z","updated_at":"2025-08-01T08:34:07.559Z","avatar_url":"https://github.com/SOF3.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ChoosePlayer\n\nAPI plugin for choosing a player interactively.\n\n## API\n\n### Let player select another player\n\nThis API method opens a dialog to let player `$chooser` choose a player,\nthen returns the name and UUID of the chosen player.\n\n```php\npublic static function ChoosePlayer::chooseCallback(\n    Player $chooser,\n    Closure $onSelect,\n    Closure $onCancel,\n    Closure $filter = null,\n    string $text = \"\",\n) : ChoosePlayerResult;\n```\n\n`$filter` are suggestion filters.\nThe `Filters` helper class can be used for creating filters.\n\n`ChoosePlayerResult` has two public fields: `string $name` and `string $uuid`.\n`$name` is the name of the player (which may or may not be in the correct case),\nand `$uuid` is the human-readable 36-character player UUID string.\nThe consistency between name and UUID are provided\non a best-effort basis by the suggester plugin,\nbut may be inaccurate if the suggester plugin is out of sync.\n\nAn example plugin that provides an op command:\n\n```php\n\u003c?php\n\nuse pocketmine\\command\\{Command, CommandSender};\nuse pocketmine\\player\\Player;\nuse pocketmine\\plugin\\PluginBase;\n\nuse SOFe\\ChoosePlayer\\{ChoosePlayer, ChoosePlayerResult};\n\nclass Main extends PluginBase {\n    public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool {\n        if(!($sender instanceof Player)) {\n            $sender-\u003esendMessage(\"This command can only be used in-game\");\n            return true;\n        }\n\n        ChoosePlayer::chooseCallback($sender, function(ChoosePlayerResult $result) use($sender) : void {\n            $chosenPlayerName = $result-\u003ename;\n            $this-\u003egetServer()-\u003eaddOp($chosenPlayerName);\n            $sender-\u003esendMessage(\"opped $chosenPlayerName\");\n        }, function() use($sender) : void {\n            $sender-\u003esendMessage(\"Operation cancelled\");\n        }, Filters::isnt($sender))\n\n        return true;\n    }\n}\n```\n\n### Provide suggestions\n\nUse this API method to provide more ways of selecting players.\n\n```\npublic static function \\SOFe\\ChoosePlayer\\ChoosePlayer::suggest(\\SOFe\\ChoosePlayer\\Suggester $suggester) : void;\n```\n\nSee [`OnlinePlayerSuggester`](src/online.php) for example usage.\nA few points to note:\n\n- `getId()` should return a fully-qualified, consistent, unique identifier,\n    because it is saved in the usage history for players.\n- `getDisplayName()` is used in the dialog where player selects the suggester.\n    Feel free to decorate this name!\n- `suggest` is an [async iterator](https://sof3.github.io/await-generator/traverser/async-iterators.html).\n    - TLDR: Implement the method like a normal await-generator async function\n        (it does not have to be async if you don't need to).\n        Simply write `yield $suggestion =\u003e Traverser::VALUE` for each suggestion.\n    - Only a small batch of suggestions (20 by default) are displayed at a time.\n        if possible, try loading no more than 20 suggestions at a time.\n    - ChoosePlayer throws a `TerminateSuggestionsException`\n        in the async iterator when the player stops selecting.\n        You may want to wrap your code with try-finally blocks\n        if there are resources you need to close.\n\n## Building\n\nTo compile this plugin to phar, you need to use Composer.\n\n```\ncomposer install\ncomposer build\n```\n\nThe output phar is generated in `hack/ChoosePlayer.phar`.\n\nYou can also find development builds in\n[GitHub Actions](https://github.com/SOF3/ChoosePlayer/actions)\n(click into a run page and scroll to bottom)\nor on [Poggit](https://poggit.pmmp.io/ci/SOF3/ChoosePlayer/~).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsof3%2Fchooseplayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsof3%2Fchooseplayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsof3%2Fchooseplayer/lists"}