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

[NEW API 1.4] An issue with the getLevel($name) method of the Server Class

Comments in 'Plugin Development' started by blocksandgold, Jun 16, 2014.

  1. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    That's what I suppose when i run my plugin :

    This code takes place somewhere in the onEnable() function :
    PHP:
          $world $this->getServer()->getLevel($w);
           if (
    $world == null) {
             
    Main::log("WARNING","World ".$w." not loaded. Config is load with the worldname");
           }
    i got this on the logfile :

    09:34:42 [WARNING] [bag_zone] World world not loaded. Config is load with the worldname


    Anybody can confirm ?
  2. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    I have the same issue on another plugin, the getLevel() is called after the onEnable()

    PHP:
                $level $this->getServer()->getLevel($levelname);

                 if (
    $level == null) {
                   
    $sender->sendMessage("Warp level is not loaded");
                   return 
    true;
                 }
    Is there a bug in the getLevel() method on the last build ?

    I change the thread title...
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use === not == for comparing false, true, 0 and null.
  4. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    === is to add the type in the test, but without the type my comparaison is already true.
    however is tried with === and that don't fix my issue.
    I cannot get the level from his name with this command :(
    $level = $this->getServer()->getLevel($levelname);
  5. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    That function gets the level based on the ID, just write a function that loops through $this->getServer()->getLevels() and checks if $level->getName() === $name.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Thanks! I thought it was because of some threading things :)
  7. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    OOOOOkkk thx !
    its a recent change no ?

    I found that in the source code :
    PHP:
    public function getLevelByName($name)
    ===> I fixed and that works. Thx again.
    Last edited: Jun 16, 2014
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What about this?
    Code:
    Fatal error: Uncaught exception 'Exception' with message 'Tried to modify an empty Chunk' in phar://C:/coding/_New-API/PocketMine-MP.phar/src/pocketmine/level/format/generic/EmptyChunkSection.php:67
    Stack trace:
    #0 phar://C:/coding/_New-API/PocketMine-MP.phar/src/pocketmine/level/format/generic/BaseChunk.php(160): pocketmine\level\format\generic\EmptyChunkSection->setBlock(8, 7, 0, 35, 1)
    #1 phar://C:/coding/_New-API/PocketMine-MP.phar/src/pocketmine/level/Level.php(556): pocketmine\level\format\generic\BaseChunk->setBlock(8, 55, 0, 35, 1)
    #2 C:\coding\LegionPE-Delta\LegionPE-Delta\src\pemapmodder\utils\spaces\CuboidSpace.php(64): pocketmine\level\Level->setBlock(Object(pocketmine\math\Vector3), Object(pocketmine\block\Wool), false, false, true)
    #3 C:\coding\LegionPE-Delta\LegionPE-Delta\src\pemapmodder\legionpe\hub\Team.php(81): pemapmodder\utils\spaces\CuboidSpace->setBlocks(Object(pocketmine\block\Wool))
    
    Is this a PocketMine issue or my issue?
  9. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    Don't you tried to set a block at a location wich is inside a not already generated chunk ?
    In your plugin (Team.php(81))

Share This Page

Advertisement