1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Level Error

Discussion in 'Development' started by A354-PH, Jan 27, 2019.

  1. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    Anyone know how to fix this?
    ERROR:
    Code:
    [05:22:13] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to bedwars\LevelManager::addLevel() must be an instance of pocketmine\level\Level, null given, called in phar:///home/minecraft/plugins/BedWars v1.3.phar/src/bedwars/commands/subcommands/LevelSubcommand.php on line 64" (EXCEPTION) in "plugins/BedWars v1.3.phar/src/bedwars/LevelManager" at line 138
    CODE (LevelManager):
    PHP:
     /**
         * @param Level $level
         * @param string $levelName
         * @param null $data
         */
        
    public function addLevel(Level $levelstring $levelName$data null) { //Line 138
            
    $data is_array($data) ? $data $this->defaultLevelData;
            
    $data["levelName"] = $level->getName();
            
    $data["folderName"] = $level->getFolderName();
            
    $data["name"] = $levelName;
            
    $this->levels[$levelName] = new BedWarsLevel($data);
        }
    }
    CODE (LevelSubcommand):
    PHP:
    case "add":
                    if(!(
    count($args) > 2)) {
                        
    $sender->sendMessage(BedWars::getPrefix()."§cUsage: §7/bw level add <level> <customLevelName>");
                        break;
                    }
                    if(!
    $this->getPlugin()->getServer()->isLevelGenerated($args[1])) {
                        
    $sender->sendMessage(BedWars::getPrefix()."§cLevel {$args[1]} does not found!");
                        break;
                    }
                    if(
    $this->getPlugin()->getLevelManager()->levelExists($args[2])) {
                        
    $sender->sendMessage(BedWars::getPrefix()."§cLevel {$args[2]} is already added!");
                        break;
                    }
                    
    $this->getPlugin()->getLevelManager()->addLevel($this->getPlugin()->getServer()->getLevelByName($args[1]), $args[2]); // line 64
                    
    $sender->sendMessage(BedWars::getPrefix()."§aLevel {$args[2]} added!");
                    break;
     
    Last edited: Jan 27, 2019
  2. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    Anyone xd
     
  3. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    PHP:
    $this->getPlugin()->getServer()->getLevelByName($args[1]);
    This returns null, does the level exist and is it loaded?
    PHP:
    Server->loadLevel($args[1]);
     
  4. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    It does exists but it isnt loaded
     
  5. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    Then load it
     
    GiantQuartz likes this.
  6. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    Now its working =)
     
    Diduhless likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.