I have two plugins: 1: Used for right click on NPC PHP: public function onUseGuide(DataPacketReceiveEvent $event) { $player = $event->getPlayer(); $pk = $event->getPacket(); if ($pk instanceof InventoryTransactionPacket) { if ($pk->transactionType === InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY) { if ($pk->trData->actionType === InventoryTransactionPacket::USE_ITEM_ON_ENTITY_ACTION_INTERACT) {... 2: Used for right click on AIR and COMPASS in hand.. Go Home PHP: public function onUseHubInventory(DataPacketReceiveEvent $event) { $player = $event->getPlayer(); $pk = $event->getPacket(); if ($pk instanceof InventoryTransactionPacket) { if ($pk->transactionType === InventoryTransactionPacket::TYPE_USE_ITEM) { if ($pk->trData->actionType === InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_AIR) { ... Problem: I click by NPC and teleport to other world. And there fired #2 (player view - AIR). Player teleport to home... How I can prevent twice DataPacketReceiveEvent?
Because you registered 2 listeners for the same event thats why both will fire, combine them together in 1 function
Cancel the event. If the second event doesn't ignore cancelled events, it is a bug. By the way, cancelled events are planned to be ignored by default as of 4.0.0