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

emtpy level name?

Comments in 'Plugin Development' started by cake23, Feb 14, 2016.

  1. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Does anyone know what this means?
    Code:
    [11:18:07] critical> "Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'AuraPE v1.0.0': Invalid empty level name on AuraPE\Main
    [11:18:07] critical> pocketmine\utils\LevelException: "Invalid empty level name" (EXCEPTION) in "/src/pocketmine/Server" at line 1150
    
    My Code:
    PHP:
    public function onInteract(PlayerInteractEvent $event) {
            
    $player $event->getPlayer();
            
    $block $event->getBlock();
            
    $sign $event->getPlayer()->getLevel()->getTile($block);
            if(
    $sign instanceof \pocketmine\tile\Sign) {
                if (
    $this->schildRegistrieren === false) {
                    
    $text $sign->getText();
                    
    $level $this->getServer()->getLevelByName($text[1]);
                    if (
    $text[0] === $this->prefix) {
                        
    $inDerWelt 0;
                        if(
    $inDerWelt 16 && !($text[3] === "§cVoll")) {
                            
    $teleportSound = new EndermanTeleportSound($player);
                            
    $player->getLevel()->addSound($teleportSound);
                            
    $this->getServer()->loadLevel($level);
                            
    $player->teleport($level->getSafeSpawn());
                            
    $player->getInventory()->clearAll();
                            
    $inDerWelt++;
    Thanks!
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Server::loadLevel() accepts a string, so put your level name, not your level's object.
    AndrewBit and cake23 like this.
  3. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Thank you, i will try it out :3
  4. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    How I can get the levelname?
    with $level->getName();
    or with $levelName = $this->getServer()->getLevelByName("aurape")->getName();
    Thanks! :D
  5. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    why not "aurape" directly? but they are correct :D
    cake23 likes this.
  6. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Lol....sorry haha :'D
    Thank you haha xD <3
  7. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Oh men..now i get this error :/
    http://prnt.sc/a36jm3
    Can you help me? ._.
  8. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    show edited code?
    cake23 likes this.
  9. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    PHP:
    if($sign instanceof \pocketmine\tile\Sign) {
                if (
    $this->schildRegistrieren === false) {
                    
    $text $sign->getText();
                    
    $levelName $text[1];
                    
    $level $this->getServer()->getLevelByName($text[1]);
                    if (
    $text[0] === $this->prefix) {
                        
    $inDerWelt 0;
                        if(
    $inDerWelt 16 && !($text[3] === "§cVoll")) {
                            
    $teleportSound = new EndermanTeleportSound($player);
                            
    $player->getLevel()->addSound($teleportSound);
                            
    $this->getServer()->loadLevel($levelName);
                            
    $player->teleport($level->getSafeSpawn());
                            
    $player->getInventory()->clearAll();
                            
    $inDerWelt++;
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Genius I am, I knew that someone would have asked this 18 months ago. :D
  11. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Omg sorry, but I dont get it. xD
  12. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    do you know the /worlds folder? are there another folders on there with name? those folder's name are the one will be got by Server::loadLevel()
  13. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd

Share This Page

Advertisement