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

is this possible? (Config)

Comments in 'Plugin Development' started by korado531m7, Mar 28, 2016.

  1. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    load Saved yml config on website. and list up.
    is this possible?

    For ex, here's the yml
    Code:
    test:
      item:
        - 3
        - 5
      type: 1
    
    and load on website,
    Test has 3, 5 item and type is 1
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You can load the data from website in onEnable and save it. According to @shoghicp, it is acceptable to execute long thread-blocking operations when the plugin is enabled, so you don't need to use a task for that.
    applqpak likes this.
  3. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    He wants the website to display the config
  4. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    Yes. And I want to extract config on website, then show.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You mean load from website, right?
    1. Use Utils::getURL() to download the raw content of the web-served file as a string
    2. Use yaml_parse() to parse the string into an array

    See this example that parses the default pocketmine.yml file using the GitHub repo:

    PHP:
    use pocketmine\utils\Utils;

    public function 
    onEnable(){
      
    $url "https://raw.githubusercontent.com/PocketMine/PocketMine-MP/master/src/pocketmine/resources/pocketmine.yml";
      
    $raw Utils::getURL($url);
      
    $parsed yaml_parse($raw);
      
    var_dump($parsed["debug"]);
    Output:
    Code:
    array(2) {
      ["level"]=>
      int(1)
      ["commands"]=>
      bool(false)
    }
    korado531m7 likes this.
  6. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    Thank you a lot! I'll test later!

Share This Page

Advertisement