Error on Interact

Discussion in 'Development' started by BlawoHD, May 29, 2019.

  1. BlawoHD

    BlawoHD Silverfish

    Messages:
    21
    GitHub:
    BlawoHD
    How i fix this error?

    PHP:
    2019-05-29 [17:26:41] [Server thread/CRITICAL]: Error"Call to a member function getItemInHand() on null" (EXCEPTIONin "plugins/LobbyItems - BlawoHD/src/BlawoHD/LobbyItems" at line 53
    2019
    -05-29 [17:26:41] [Server thread/DEBUG]: #0 src/pocketmine/plugin/MethodEventExecutor(38): BlawoHD\LobbyItems->onInteract(pocketmine\event\player\PlayerInteractEvent object)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #1 src/pocketmine/plugin/RegisteredListener(98): pocketmine\plugin\MethodEventExecutor->execute(BlawoHD\LobbyItems object, pocketmine\event\player\PlayerInteractEvent object)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #2 src/pocketmine/event/Event(99): pocketmine\plugin\RegisteredListener->callEvent(pocketmine\event\player\PlayerInteractEvent object)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #3 src/pocketmine/level/Level(1914): pocketmine\event\Event->call()
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #4 src/pocketmine/Player(2417): pocketmine\level\Level->useItemOn(pocketmine\math\Vector3 object, pocketmine\item\ItemBlock object, integer 2, pocketmine\math\Vector3 object, pocketmine\Player object, boolean 1)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #5 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(149): pocketmine\Player->handleInventoryTransaction(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #6 src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket(158): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleInventoryTransaction(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #7 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(109): pocketmine\network\mcpe\protocol\InventoryTransactionPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #8 src/pocketmine/network/mcpe/protocol/BatchPacket(123): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #9 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(109): pocketmine\network\mcpe\protocol\BatchPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #10 src/pocketmine/Player(3124): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #11 src/pocketmine/network/mcpe/RakLibInterface(169): pocketmine\Player->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #12 vendor/pocketmine/raklib/src/server/ServerHandler(99): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string 194.230.158.109 45681, raklib\protocol\EncapsulatedPacket object, integer 0)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #13 src/pocketmine/network/mcpe/RakLibInterface(109): raklib\server\ServerHandler->handlePacket()
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #14 src/pocketmine/network/mcpe/RakLibInterface(99): pocketmine\network\mcpe\RakLibInterface->process()
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #15 vendor/pocketmine/snooze/src/SleeperHandler(123): pocketmine\network\mcpe\RakLibInterface->pocketmine\network\mcpe\{closure}()
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #16 vendor/pocketmine/snooze/src/SleeperHandler(85): pocketmine\snooze\SleeperHandler->processNotifications()
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #17 src/pocketmine/Server(2339): pocketmine\snooze\SleeperHandler->sleepUntil(double 1559143601.6201)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #18 src/pocketmine/Server(2196): pocketmine\Server->tickProcessor()
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #19 src/pocketmine/Server(1775): pocketmine\Server->start()
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #20 src/pocketmine/PocketMine(266): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string /home/Lobby/, string /home/Lobby/plugins/)
    2019-05-29 [17:26:41] [Server thread/DEBUG]: #21 (1): require(string phar:///home/Lobby/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
     
  2. HeyDeniis_

    HeyDeniis_ Witch

    Messages:
    52
    please, send the code in the line 54.

    you should use:

    PHP:
    $item $e->getPlayer()->getInventory()->getItemInHand();

     
  3. BlawoHD

    BlawoHD Silverfish

    Messages:
    21
    GitHub:
    BlawoHD
    PHP:
    $item $player->getInventory()->getItemInHand(); //Line 53
     
  4. Mohagames205

    Mohagames205 Silverfish

    Messages:
    17
    GitHub:
    mohagames205
    Please send us your whole code, where do you define $player?
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,558
    GitHub:
    muqsit
    Why use getItemInHand() in PlayerInteractEvent? Just use $item = $event->getItem();
     
    wolfdale and StevenS like this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.