Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

give player item on join crash

Comments in 'Plugin Development' started by BalAnce, Jul 26, 2015.

  1. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    PHP:
        public function onJoin(PlayerJoinEvent $ev){
            
    $player $ev->getPlayer();
            if (
    $player->getLastPlayed() === null){

            
    $player->getInventory()->clearAll();
            
    $inv $player->getInventory();
                
    $item = new Item(345,0,1);
                
    $inv->addItem($item);
           
        }
        }
    Code ^
    It gives me a crash dump tho.
    Code:
    [01:09:07] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'ServerSelector v0.1': Argument 1 passed to pocketmine\entity\Entity::__construct() must implement interface pocketmine\level\format\FullChunk, integer given, called in /Users/newuser/Desktop/Pocketmine/plugins/ServerSelector/src/serverselector/main.php on line 86 and defined on serverselector\main
    [01:09:07] [Server thread/NOTICE]: RuntimeException: "Argument 1 passed to pocketmine\entity\Entity::__construct() must implement interface pocketmine\level\format\FullChunk, integer given, called in /Users/newuser/Desktop/Pocketmine/plugins/ServerSelector/src/serverselector/main.php on line 86 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/entity/Entity__64bit" at line 207
  2. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Try:
    PHP:
    $inv->addItem(345,0,10;
  3. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    No that is not how it works it takes a item as paramatar not integer
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Does it still happen if you remove your onJoin handler? It doesn't seem to be related to your plugin.

    Also, use Item::get() instead of new Item().
    MCPEPIG likes this.
  5. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    no it does not happen if i remove the join event
  6. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    maybe this?
    PHP:
     public function onJoin(PlayerJoinEvent $ev){
            
    $player $ev->getPlayer();
            if (
    $player->getLastPlayed() === null){

            
    $player->getInventory()->clearAll();
            
    $inv $player->getInventory();
                
    $item Item::get(Item::COMPASS,0,1);
                
    $inv->addItem($item);
          
        }
        }
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Enable debug in pocketmine.yml and show us the backtrace.

Share This Page

Advertisement