Closed HashimTheArab closed 3 years ago
Furry
I can confirm its crashing, tried it myself.
Everything isn’t fully constructed and created at PlayerLoginEvent. Just do whatever you need to do on PlayerJoinEvent or whatnot
Yea I know I just thought it should return ?InventoryManager
Then it would still crash, just in a different place.
Yea but the error would make sense "cannot call function addItem on null", go ahead and close it I guess
edit: I misunderstood Dylan
if ( !is_null($player->getNetworkSession()) && $player->isConnected() && $player->getNetworkSession()->getInvManager() instanceof InventoryManager ) {
try to add this check @Prim69
A solution I've previously considered to this and other problems is to move the PlayerLoginEvent
call out of the Player
constructor.
Issue description
Steps to reproduce the issue
$player->getInventory()->addItem() in PlayerLoginEvent
OS and versions
Plugins
Plugins (2): Core v3.2.0, DevTools v1.15.0+dev
$player->getInventory()->addItem(VanillaItems::GOLDEN_HOE()); }
Crashdump, backtrace or other files