{"id":15142866,"url":"https://github.com/dresnite/npcdialog","last_synced_at":"2025-10-29T19:47:57.560Z","repository":{"id":65441110,"uuid":"281805459","full_name":"dresnite/npcdialog","owner":"dresnite","description":"💭 PocketMine-MP virion to add dialogs to entities easily","archived":false,"fork":false,"pushed_at":"2023-11-28T21:26:04.000Z","size":42,"stargazers_count":69,"open_issues_count":1,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-30T20:51:39.569Z","etag":null,"topics":["hacktoberfest","minecraft","pmmp","pmmp-plugin","pocketmine","pocketmine-plugin","virion"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dresnite.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}},"created_at":"2020-07-22T23:39:55.000Z","updated_at":"2024-09-25T11:18:43.000Z","dependencies_parsed_at":"2023-10-04T16:03:10.853Z","dependency_job_id":"5c66dd3f-b3f3-486c-9aee-9eb8541100ac","html_url":"https://github.com/dresnite/npcdialog","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/dresnite%2Fnpcdialog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dresnite%2Fnpcdialog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dresnite%2Fnpcdialog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dresnite%2Fnpcdialog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dresnite","download_url":"https://codeload.github.com/dresnite/npcdialog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237882172,"owners_count":19381176,"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":["hacktoberfest","minecraft","pmmp","pmmp-plugin","pocketmine","pocketmine-plugin","virion"],"created_at":"2024-09-26T10:00:45.306Z","updated_at":"2025-10-23T20:30:19.073Z","avatar_url":"https://github.com/dresnite.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NpcDialog\n\n### Download\n\nThe compiled phar is available [on poggit](https://poggit.pmmp.io/ci/dresnite/NpcDialog/NpcDialog)\n\n### How to use\n\nFirst, you have to register the virion, you can do this during the `onEnable()` of your plugin main class.\n\n```php\npublic function onEnable(): void {\n    NpcDialog::register($this);\n}\n```\n\nThen you have to spawn or get the object of the entity you want to have the dialog form. For\nthis example, I will spawn a zombie using PocketMine built-in methods.\n\n ```php\n$nbt = Entity::createBaseNBT($player, null, $player-\u003eyaw, $player-\u003epitch);\n$entity = Entity::createEntity(\"Zombie\", $player-\u003elevel, $nbt);\n$entity-\u003espawnToAll();\n \n$entity-\u003esetNameTag(\"Jerry The Zombie!\");\n ```\n\nFinally you will have to create the form and pair it with the entity.\n\n```php\n//Add a new form with the text \"This is the dialog text\"\n$form = new DialogForm(\"This is the dialog text\");\n//Add a button with the text \"Hi\" and the optional command \"say Hi!!\" and a listener for when the button is clicked\n$form-\u003eaddButton(\"Hi\", \"say Hi!!\", function(Player $player) {\n    $player-\u003esendMessage(\"Hi!!\");\n});\n//Set a listener for when the form is opened\n$form-\u003esetOpenListener(function(Player $player) {\n    $player-\u003esendMessage(\"You opened the form!\");\n});\n//Set a listener for when the form is closed\n$form-\u003esetCloseListener(function(Player $player) {\n    $player-\u003esendMessage(\"You closed the form!\");\n});\n//Pair the form with the entity so it will show when the entity is right-clicked\n$form-\u003epairWithEntity($entity);\n```\n\nThis can be trimmed down to a single line:\n\n```php\n(new DialogForm(\"This is the dialog text\", function(Player $player){ $player-\u003esendMessage(\"You opened the form!\"); }, function(Player $player){ $player-\u003esendMessage(\"You closed the form!\"); }))-\u003eaddButton(\"Hi\", \"say Hii!!\", function(Player $player){ $player-\u003esendMessage(\"Hi!!\"); })-\u003epairWithEntity($entity);\n```\n\nThe result of this example would be an entity showing this when it's right-clicked (or hold in the mobile versions):\n\n![Example](https://i.imgur.com/468mQKF.png)\n\nYou can also force the form to show by using the `open(Player $player)` method.\n\n```php\n$form-\u003eopen($player);\n```\n\nor close it by using the `close(Player $player)` method.\n\n```php\n$form-\u003eclose($player);\n```\n\nWhen the user clicks on a button, it's `$submitListener` listener will be called. The command will not be executed by\ndefault, you have to do it yourself (the command parameter does not need to be set). Clicking a button will force the\nform to close in order to prevent the user from being locked in the form (the client usually will request the form to be\nclosed when the user clicks on a button, but better be safe).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdresnite%2Fnpcdialog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdresnite%2Fnpcdialog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdresnite%2Fnpcdialog/lists"}