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

YAML help

Comments in 'Plugin Development' started by MrGenga, Oct 12, 2015.

  1. MrGenga
    Offline

    MrGenga Active Member

    Joined:
    Jul 24, 2015
    Posts:
    75
    Minecraft User:
    MrGenga
    Hi! I need help, with yaml: "yaml_parse(): end of stream reached without finding document 0" (E_WARNING) in "/src/pocketmine/utils/Config" at line 143
    My code:
    PHP:
    <?php
    namespace FS;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\event\block\SignChangeEvent;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\level\particle\FloatingTextParticle;
    class 
    Main extends PluginBase implements Listener {
    public function 
    onEnable() {
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
    $this->saveDefaultConfig();
    }
    public function 
    onJoin(PlayerJoinEvent $ev) {
    foreach(
    $this->getConfig()->getAll() as $fs) {
    $pos $this->stringToVector3($fs["xyz"]);
    $level $this->getServer()->getLevelByName($fs["level"]);
    $title $fs["title"];
    $text $fs["text"];
    $ft = new FloatingTextParticle($pos,$text,$title);
    $level->addParticle($ft);
    }
    }
    public function 
    stringToVector3($str) {
    $xyz explode(" ",$str);
    return new 
    Vector3($xyz[0],$xyz[1],$xyz[2]);
    }
    public function 
    onChange(SignChangeEvent $ev) {
    if(
    $ev->getLine(0)=="[FS]") {
    $config $this->getConfig()->getAll();
    $name str_replace(" """$ev->getLine(1));
    $lines $ev->getLines();
    unset(
    $lines[0]);
    unset(
    $lines[1]);
    sort($lines);
    $config[$name]["xyz"] = $ev->getBlock()->getX() . " " $ev->getBlock()->getY() . " " $ev->getBlock()->getZ();
    $config[$name]["level"] = $ev->getBlock()->getLevel()->getName();
    $config[$name]["text"] = implode("\n"$lines);
    $config[$name]["title"] = $ev->getLine(1);
    $ft = new FloatingTextParticle($this->stringToVector3($config[$name]["xyz"]), $config[$name]["text"], $config[$name]["title"]);
    $ev->getBlock()->getLevel()->addParticle($ft);
    $this->getConfig()->setAll($config);
    $this->getConfig()->save();
    }
    }
    }
  2. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Do you know where the problem is?
  3. MrGenga
    Offline

    MrGenga Active Member

    Joined:
    Jul 24, 2015
    Posts:
    75
    Minecraft User:
    MrGenga
    In onEnable and in SignChangeEvent
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Hey, everyone in this thread, please open your eyes and read the error.
    YAML error.
  5. MrGenga
    Offline

    MrGenga Active Member

    Joined:
    Jul 24, 2015
    Posts:
    75
    Minecraft User:
    MrGenga
    And... It is a problem with § symbol in config, yes?
  6. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    You should really stop giving advice
    Like @PEMapModder said this a YAML error it had to do with your config file

    I am assuming the error has to do with you not having the config set up properly
    Code:
    --- #start of file
    #Config stuff
    ... #end of file
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    This will change $lines into a value that is completely useless for most people. Please don't post if you don't know what you are doing.
    CavinMiana and Legoboy0215 like this.

Share This Page

Advertisement