-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDialogueTest.php
More file actions
55 lines (47 loc) · 1.38 KB
/
DialogueTest.php
File metadata and controls
55 lines (47 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* @name DialogueTest
* @author alvin0319
* @main alvin0319\DialogueTest\DialogueTest
* @version 1.0.0
* @api 4.0.0
*/
declare(strict_types=1);
namespace alvin0319\DialogueTest;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\player\Player;
use pocketmine\plugin\PluginBase;
use ref\libNpcDialogue\form\NpcDialogueButtonData;
use ref\libNpcDialogue\libNpcDialogue;
use ref\libNpcDialogue\NpcDialogue;
final class DialogueTest extends PluginBase{
public function onEnable() : void{
if(!libNpcDialogue::isRegistered()){
libNpcDialogue::register($this);
}
$this->getServer()->getCommandMap()->register("test", new class extends Command{
public function __construct(){
parent::__construct("npc", "npc test");
}
public function execute(CommandSender $sender, string $commandLabel, array $args) : void{
if(!$sender instanceof Player){
return;
}
$npcDialogue = new NpcDialogue();
$npcDialogue->addButton(NpcDialogueButtonData::create()
->setName("Test")
->setText("Test123")
->setClickHandler(function(Player $player) : void{
$player->sendMessage("Hello world!");
})
->setForceCloseOnClick(true)
);
$npcDialogue->setNpcName("Test NPC");
$npcDialogue->setDialogueBody("Test Body");
$npcDialogue->setSceneName("TEST");
$npcDialogue->sendTo($sender);
}
});
}
}