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

Save bug

Comments in 'Plugin Development' started by Asparanc, Apr 18, 2015.

  1. Asparanc
    Offline

    Asparanc Active Member

    Joined:
    Feb 20, 2015
    Posts:
    210
    Minecraft User:
    Asparanc
    Hi all ! I've a big problem with yaml save. When the server run i stock informations in array() and when I stop it I ask to the plugin to save them in a file but it do anyting.
    PHP:
    public function onDisable(){
    $this->save();
    }
    public function 
    save(){
    $this->config = new Config$this->getDataFolder() . "Config.yml"Config::YAML);
    $this->config->setAll($this->money);
    $this->config->save();
    $this->config->setAll($this->rankshop);
    $this->config->save();
    $this->config->setAll($this->auth);
    $this->config->save();
    $this->config->setAll($this->ranks);
    $this->config->save();
    $this->config->setAll($this->chat);
    $this->config->save();
    $this->config->setAll($this->ranklist);
    $this->config->save();
    $this->config->setAll($this->shop);
    $this->config->save();
    $this->config->setAll($this->sell);
    $this->config->save(); }
    Can you help me ?
  2. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    *passes out*
  3. Asparanc
    Offline

    Asparanc Active Member

    Joined:
    Feb 20, 2015
    Posts:
    210
    Minecraft User:
    Asparanc
    What ?
  4. Martin77Epic
    Offline

    Martin77Epic Banned

    Joined:
    Mar 6, 2015
    Posts:
    164
    Minecraft User:
    CookieMonsterPE
    A Question LDX you Are on 15 ? 15
  5. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    PHP:
    $data = [
      
    "Money" => $this->money,
      
    "RankShop" => $this->rankshop,
      
    "Auth" => $this->auth,
      
    "Ranks" => $this->ranks,
      
    "Chat" => $this->chat,
      
    "RankList" => $this->ranklist,
      
    "Shop" => $this->shop,
      
    "Sell" => $this->sell
    ];
    if(!
    is_dir($this->getDataFolder())) {
      
    mkdir($this->getDataFolder());
    }
    foreach(
    $data as $file => $datum) {
      
    file_put_contents($this->getDataFolder() . "$file.yml",yaml_emit($datum));
    }
    What?
    Asparanc likes this.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Don't post irrelevant posts please.
    You keep overriding your config.
    Also you should not define $this->config yourself.
    Asparanc likes this.
  7. Asparanc
    Offline

    Asparanc Active Member

    Joined:
    Feb 20, 2015
    Posts:
    210
    Minecraft User:
    Asparanc
    It give me :
    Code:
    Error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting '('
    File: /AventCube/src/AventCube/Main
    Line: 80
    Type: E_PARSE
    
    THIS CRASH WAS CAUSED BY A PLUGIN
    
    Code:
    [71]   "Ranks" => $this->ranks,
    [72]   "Chat" => $this->chat,
    [73]   "RankList" => $this->ranklist,
    [74]   "Shop" => $this->shop,
    [75]   "Sell" => $this->sell
    [76] ];
    [77] if(!is_dir($this->getDataFolder())) {
    [78]   mkdir($this->getDataFolder());
    [79] }
    [80] foreach($data as Players => $datum) {
    [81]   file_put_contents($this->getDataFolder() . "$file.yml",yaml_emit($datum));
    [82] }
    [83] }
    [84]
    [85] 
    Ok
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You forgot $ on line 80 for Players (should be $file)
    Asparanc and LDX like this.
  9. Asparanc
    Offline

    Asparanc Active Member

    Joined:
    Feb 20, 2015
    Posts:
    210
    Minecraft User:
    Asparanc
    Thx for help :)
    LDX likes this.

Share This Page

Advertisement