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

Fatal error: Call to a member function getName()

Comments in 'Plugin Development' started by tigerza118, Jun 17, 2015.

  1. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    Fatal error: Call to a member function getName() on null in /home/pm/spawn/plugins/PMLove-61e1df65cb219719ecdde3e2499596dad3016d2c/src/Love/Main.php on line 150
    PHP:
    private function acceptMarriage(CommandSender $sender,array $args) { //Functions to say "YES" to a propsal
    $player strtolower($sender->getName());
                
    $playercase $sender->getPlayer()->getName();
        if(empty(
    $args[1])) {
            
    $sender->sendMessage(TextFormat::RED."[<3] Usage: /l yes <player>");
            return 
    true;
                }
                
    $spouseexact =  $this->getServer()->getPlayerExact($args[1]);
                
    $gtsndr strtolower($args[1]);
                
    $spousename $spouseexact->getName();
                        if(!
    $spouseexact instanceof Player) {
                        
    $sender->sendMessage(TextFormat::RED."[<3] That player is not online right now");
                            return 
    true;
                }
                if(!
    $this->getUserTEMP($gtsndr$player)) {
                
    $sender->sendMessage(TextFormat::YELLOW."[<3] That player did not propose to you");
                    return 
    true;
                    }
                    
    $playerget strtolower($sender->getName());
                    
    $this->removeUserTEMP($gtsndrstrtolower($sender->getName()));
                    
    $this->setUser($gtsndr$player);
                    
    $this->setUser($player$gtsndr);
                    
    $sender->sendMessage(TextFormat::GREEN."[<3] You have accepted $spouseexact's proposal!");
                    
    $spouseexact->sendMessage(TextFormat::GREEN."[<3] You are now married to $player!");
                    
    $sender->setNameTag("[<3] ".$sender->getName());
                    
    $spouseexact->setNameTag("[<3] ".$spouseexact->getName());
                    
    $this->getServer()->BroadcastMessage(TextFormat::GREEN."$player is now married to $spouseexact!");
                        return 
    true;
                            }
  2. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    Try
    PHP:
    //$playercase = $sender->getPlayer()->getName(); error
    $playercase $sender->getName();
  3. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    How many times I said that $sender is already an instance of Player!?
    Last edited: Jun 17, 2015
    Xenturio, xiaoq and PEMapModder like this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It's pointless. He only knows how to copy code.
    xiaoq and Angelo Vidrio like this.
  5. Angelo Vidrio
    Offline

    Angelo Vidrio Active Member Plugin Developer

    Joined:
    Jan 16, 2014
    Posts:
    123
    Plugins:
    5
    Minecraft User:
    LilCrispy45
    Agreed
    xiaoq likes this.
  6. xiaoq
    Offline

    xiaoq Active Member

    Joined:
    Dec 23, 2014
    Posts:
    232
    Minecraft User:
    xiaoq
    [When I learn plugin, someone told me] You can look up another people code if you don't know how to code, but you must understand what is that code mean.
  7. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    PEMapModder likes this.
  8. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    $this->solution->closed();
  9. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    $Xenturio = $event->getPlayer()
    $Xenturioname = $Xenturio->getName()
    $Xenturio->sendMeassage("Tell that to a staff, " . $Xenturioname . "!!!");
    Lets see who can help me spot the error... XD
  10. xiaoq
    Offline

    xiaoq Active Member

    Joined:
    Dec 23, 2014
    Posts:
    232
    Minecraft User:
    xiaoq
    it easy (; <==
  11. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Of course it is easy...

Share This Page

Advertisement