Closed SmallkingDev closed 1 year ago
Please provide reproducing code.
Please provide reproducing code.
Please provide reproducing code.
<?php
declare(strict_types=1);
namespace test;
use pocketmine\plugin\PluginBase;
use pocketmine\event\Listener;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\player\Player;
use pocketmine\event\server\DataPacketSendEvent;
use function var_dump;
final class Loader extends PluginBase implements Listener {
protected function onEnable(): void {
$this->getServer()->getPluginManager()->registerEvents($this, $this);
$this->getServer()->getCommandMap()->register("test", new class extends Command {
public function __construct() {
parent::__construct("test");
}
public function execute(CommandSender $sender, string $commandLabel, array $args): void {
if ($sender instanceof Player) {
foreach ($sender->getViewers() as $viewer) {
$viewer->setNameTag("§c§l" . $sender->getName());
}
}
}
});
}
public function onDataPacketSend(DataPacketSendEvent $event) : void {
$packets = $event->getPackets();
foreach ($packets as $packet) {
if ($packet instanceof SetActorDataPacket) {
var_dump($packet);
}
}
}
}
This problem occurs because EntityEventBroadcaster bypasses NetworkBroadcastUtils, and uses StandardPacketBroadcaster directly.
Issue description
Expected result: What was expected was that the packets sent through the broadcastEntityEvent would pass through the DataPacketSendEvent
Actual result: Currently packets sent by broadcastEntityEvent do not go through the DataPacketSendEvent
Steps to reproduce the issue
OS and versions