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

How to save multiple resources?

Comments in 'Plugin Development' started by XFuryMCPE, Jan 11, 2016.

  1. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    I'm trying to save multiple resources to the Data folder when my plugin is first loaded. all I know is "$this->saveDefaultConfig();". How do I save multiple resources? Like "items.yml" and "blocks.yml"

    PS: This is for ItemEffects lolol
  2. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Create for each YAML a config code, or do fopen, fwrite (hard)
  3. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    I create them like this:
    PHP:
    $this->config = new Config($this->getDataFolder() . "config.yml"Config::YAML, array(
    "Message" => "Hello world",
    ));
    You can create as many YAML files as you want.
  4. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    To get data from the config:
    PHP:
    echo $this->config->get("Message");
    To change something in the config:
    PHP:
    $this->config->set("Message""Bye world"); //will set the message to "Bye world"
    $this->config->save(); //saves the config
  5. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    How do I save one already made.
  6. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Umm save it? Save means to update the changes
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    $config->save();
  8. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    I usually do manual Data Saving(Without using the pocketmine\utils\Config). :p
  9. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    Code:
    $blocks = $this->getConfig("blocks.yml");
    $blocks->save;
    ?
  10. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    That's if blocks.yml already exists, and it's $blocks->save();
  11. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    PHP:
    $this->saveResource("items.yml");
    $this->saveResource("blocks.yml");
  12. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    Finally, a short, simple answer xD
    applqpak likes this.
  13. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    Lmao, next update is going to just organize everything. Another config reset pretty much. Good luck configuring it @Antisober552 xD
  14. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    ahh, nvm. :D (smfh...)

Share This Page

Advertisement