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

Solved getLevelByName Crash

Comments in 'Plugin Development' started by Tim // robske Büba, Jan 27, 2016.

  1. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    PHP:
    Fatal errorCall to undefined method robske_110\Plugin\Main::getLevelByName() in /Users/Tim/Desktop/Pocket_Server_0.13.x/plugins/TPA_HOME/src/robske_110/Plugin/Main.php on line 173
    What? My use statements:
    PHP:
    use pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Server;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\event\block\SignChangeEvent;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\Player;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\level\Level;
    And my piece of Shit err I mean code:
    PHP:
    case "home":
                if(
    $sender instanceof Player)
                {
                if(
    $this->config->get($sender->getName()) == false)
                {
                      
    $sender->getPlayer()->sendMessage("[rBServer]" TextFormat::DARK_RED " Setze erst einen Punkt mit /sethome! (ErrorCode: ERR_124_ConfigGetSenderRN_HOME)");
                      return 
    true
                }
                
    $tempPos $this->config->get($sender->getName()); //HERE IS THE CRASH
                
    $tempPosWaO $this->getLevelByName($tempPos['world']);
                
    $finalTempPos = new Position((int) $tempPos['x'], (int) $tempPos['y'], (int) $tempPos['z'], $tempPosWaO);
                
    $sender->teleport($finalTempPos);
                
    $sender->getPlayer()->sendMessage("[rBServer]" TextFormat::GREEN " Du wurdet erfolgreich nach Hause teleportiert!");
                }
                else
                {
                    
    $this->getServer()->getLogger()->info(TextFormat::DARK_RED TextFormat::BOLD "[HOME] ERR_123_ConsoleIssued_HOME");
                    return 
    true;
                }
                return 
    true;
            }
  2. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Simple problem, you forgot
    PHP:
     $this->getServer()->getLevelByName()... 
    PocketKiller likes this.
  3. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    FACEPALM thanks.

Share This Page

Advertisement