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

Solved Whats wrong?

Comments in 'Plugin Development' started by JackboyPlay, Mar 30, 2016.

  1. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    PHP:
    [15:34:14critical"Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'Jump v1.0.0': Call to a member function getText() on null on JackboyPlay\Jump\Main
    [15:34:14]critical> Error: "
    Call to a member function getText() on null" (EXCEPTION) in "/Jump/src/JackboyPlay/Jump/Main" at line 93
    Whats the error?

    Here the function:
    PHP:
    public function onSchildKlick(PlayerInteractEvent $event){
    $player $event->getPlayer();
    $block $event->getBlock();
    $tile $event->getPlayer()->getLevel()->getTile($block);
      
    $text $tile->getText();
    if(
    $tile instanceof Sign){
    if(
    $text[0] == "§c[§aJump§c]" && $text[2] == "§eLobby" && $text[3] == "§fJump1"){
    $this->jump1[$player->getName()] = true;
    $player->sendMessage("§7[§eJump§7] §aDu hast das Spiel §cJump1§a betreten!");
    }
    }
    }
  2. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    PHP:
    if($tile instanceof Sign){
  3. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Use this sorry for my mistake
    PHP:
            if($event->getBlock()->getId() == 68 || $event->getBlock()->getId() == 63) {
                
    $sign $event->getPlayer()->getLevel()->getTile($event->getBlock());
                if(
    $sign instanceof Sign) {
                    
    $text $sign->getText();
                                   if(
    $text[0] == "[Test]"){
  4. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    I have it already!
  5. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
  6. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Thanks!
    Ritch likes this.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Always remember that PHP code in a function is run from left to right, from up to down. The code above is executed before the code below. Code before an if-block is executed whether the if-block behind it is executed or not. You executed $tile->getText() without checking $tile !== null, so there is a chance that you are executing $tile->getText() when $tile is null.
  8. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    You have an deeply ironic-notfunny-good-useful way of explaining things this makes my brain explode about whether i should HATE you or fucking LOVE you
    AndrewBit likes this.
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Hmm? Ironic?
  10. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Be quiet
    @PEMapModder I know its useful for killstreaks without arrays :D

Share This Page

Advertisement