Open Yexeed opened 2 weeks ago
Hi ! just add a third argument (true) to the method NpcDialogueManager::send($player,$dialogue,true) ,
Doesn't help at all, my guy! Sample code:
$builder->setCloseListener(function(Player $player): void{
$player->sendMessage("closed");
});
$builder->setResponseListener(function(Player $player, int $btn): void{
$player->sendMessage("Pressed $btn");
});
NpcDialogueManager::send($player, $builder->build(), true);
Result: https://imgur.com/a/kVJ5rVW Pressing on the "X" button is sent by client, BUT however it doesn't gets handled, as far as I can see it, the dialogue should be a NullNpcDialogue instance, however it is not. https://github.com/Cosmoverse/NpcDialogue/blob/master/src/cosmicpe/npcdialogue/player/PlayerInstance.php#L142
Also, pressing on any response button makes dialogue stuck on the player's screen, and you can't close it nor press the button again, as I've shown on video.
- when I opened it, the “closed” line was dumped, but I did not close the dialogue.
I suspect this is due to the event being triggered on-sneak-start and on-sneak-end, causing dialogue to be sent twice.
Does the issue persist when you account for $e->isSneaking()
?
public function onShift(PlayerToggleSneakEvent $e): void{
+ if(!$e->isSneaking()) return; // player released shift key - ignore
...
}
If only it was the problem :(. My real usage-case is to open dialogue when clicking a form button. It happens once, at any time. For whatever reason, pressing on npc response button doesn't close a dialogue and makes player screen to be stuck with dialogue, can't close or press a response button.
Just a sec ago, I've tried to explicitly close a dialogue, and it worked. Here's sample code. I am just wondering why it isn't specified in docs.
$builder->addSimpleButton("TEXT", function(Player $player) use ($applyFunction): void{
$applyFunction($player);
NpcDialogueManager::remove($player);
});
A bug which is still apparent is $onClose callable doesn't gets called when player clicks "X" button.
Here's debug output, it looks like to me that dialogue should be a NullNpcDialogue
(which it is not), and close packets aren't getting handled correctly.
[15:36:12.689] [Server thread/INFO]: [CommandSaver] [15:36:12] Yexeed: cape
[15:36:13.349] [Server thread/INFO]: [SimpleDuels] TopHologram closed
string(16) "OPENING SHOWCASE"
string(16) "SENDING DIALOGUE"
[15:36:13.509] [Server thread/DEBUG]: [SkinCapes] [Yexeed] Attempting to send dialogue
string(69) "PacketReceived: NpcRequestPacket, type: RequestExecuteOpeningCommands"
string(39) "we got the dialogue status 1 (RECEIVED)"
[15:36:13.602] [Server thread/DEBUG]: [NetworkSession: Yexeed] Unhandled NpcRequestPacket: YhQGAAACMjA=
string(69) "PacketReceived: NpcRequestPacket, type: RequestExecuteClosingCommands"
string(33) "PlayerInstance: onDialogueClose()"
string(39) "$this->current_dialogue !== null ? true"
string(73) "$this->current_dialogue->dialogue === NullNpcDialogue::instance() ? false"
[15:36:14.754] [Server thread/DEBUG]: [NetworkSession: Yexeed] Unhandled NpcRequestPacket: YhQCAAACMjA=
I just can't find the trace from where closeListener get's called. Even if onDialogueClose()
works correctly, it still won't call closeListener
Upon sending a dialogue to the player, it's getting status "closed" with closeListener activating. Sample code:
Result:
Video: https://imgur.com/a/UTiEMTU
Versions:
NpcDialogue v0.1.1 (from releases)