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

yaml_parse

Comments in 'Plugin Development' started by Artide, May 20, 2015.

  1. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    I made a plugin and pocketmine is saying I cant use yaml_parse.
    PHP:
        @mkdir($this->getDataFolder(), 0777true);
            
    $qtp yaml_parse(file_get_contents($this->getDataFolder(), "config.yml"Config::YAML));
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Use \yaml_parse();

    The backslash indicates that it is in the global namespace.
  3. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Not working at all.
    PHP:
    <?php

    namespace QuickTP;

    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\plugn\Listener;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;

    class 
    Main extends PluginBase implements Listener{
       
        public function 
    onEnable(){
       
        
    $this->log("[QuickTP] - sucessfully enabled!");

        
    $this->saveDefaultConfig();
            @
    mkdir($this->getDataFolder(), 0777true);
            
    $qtp = \yaml_parse(file_get_contents($this->getDataFolder(), "config.yml"Config::YAML));
        }
       
        public function 
    onCmd(CommandSender $senderCommand $cmd$label, array $args){
       
       switch(
    $cmd->getName()){
         case 
    'setlobby':
        if(
    $sender->isOp() || $sender->hasPermission("quicktp.command.setlobby")){
          
    $x $sender->getFloorX();
          
    $y $sender->getFloorY();
          
    $z $sender->getFloorZ();
       
           
    $qtp->set("Spawn-Location", array($x$y$z));
           
    $qtp->save();
           
    $sender->sendMessage("Spawn set to: X -".$x.", Y -".$y.", Z -".$z);
           return 
    true;
       
             }
       
        else {
           
            
    $sender->sendMessage("You don't have permission to use this command.");
            return 
    false;
           
        }
           
         case 
    'lobby':
         if(
    $sender->isOp() || $sender->hasPermission("quicktp.command.lobby")){
           
    $l $qtp->get("Spawn-Location");
            
    $sender->teleport(new Position($l[0], $l[1], $l[2]));
            
    $sender->sendMessage("┬žaTeleporting...");
            return 
    true;
       
       
             }
       
        else {
           
            
    $sender->sendMessage("You don't have permission to use this command.");
            return 
    false;
           
        }
       
          }
       
        }
       
        public function 
    onTap(PlayerInteractEvent $e){
       
            
    $p $e->getPlayer();
            
    $item $e->getItem();
            
    $l $this->getConfig()->get("Spawn-Location");
           
            if(
    $item === $qtp->getNested("Item.ID") && $p instanceof Player){
               
                
    $p->teleport(new Position($l[0], $l[1], $l[2]));
                
    $p->sendMessage("Teleporting...");
            return;
               
            }
           
        }
       
        public function 
    onDisable(){
       
        
    $qtp->save();
       
        
    $this->log("[QuickTP] - disabled!");
       
        }
       
    }
  4. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Use PocketMine/utils/Config directly ;)
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What does the console say?
    Why -_-
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Oh, it's because you just don't need to pass the Config::YAML! And you should be concatating $this->getDataFolder() and "config.yml" by a `.`, not separating them as separated arguments by a `,`!
  7. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Haha, nope.

    [Server] 21:23:52 [ERROR] Could not load '/storage/sdcard0/PocketMine/plugins/compass spawn.zip' in folder '/storage/sdcard0/PocketMine/plugins/': yaml_parse(): scanning error encountered during parsing: mapping values are not allowed in this context (line 15, column 17)
    [Server] 21:23:52 [WARNING] RuntimeException: "yaml_parse(): scanning error encountered during parsing: mapping values are not allowed in this context (line 15, column 17)" (E_WARNING) in "/src/pocketmine/plugin/PluginDescription" at line 51
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Your file was corrupted.

Share This Page

Advertisement