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

Config Format Preference

Comments in 'Plugin Development' started by Muqsit, Sep 16, 2016.

  1. Muqsit
    Offline

    Muqsit Active Member

    Joined:
    Sep 9, 2015
    Posts:
    175
    Minecraft User:
    Muqsit
    What would be the best config format for a huge (60KB+ when compressed) plugin?

    - YAML (.yml)
    - JSON (.json)
    - ENUM (.txt) really?
    - PHP (.php)
  2. Intyre
    Offline

    Intyre Staff Member PocketMine Team

    Joined:
    Aug 24, 2013
    Posts:
    118
    Minecraft User:
    Intyre
    What would be the best way to figure it out? Maybe testing it yourself? Be adventurous!

    You can try YAML, that should work. Maybe JSON is faster, maybe not. How about a TXT file? Oh PHP is also possible. I hope this info helps :p
    Last edited: Sep 16, 2016
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Config format? What are you storing? If player data, I would go with SQLite (I use it a lot recently). But seriously, I don't get why people use config files to store data. For other stuff, JSON and XML are also options you should consider.
    Last edited: Sep 17, 2016
    applqpak and ImagicalGamer like this.
  4. Muqsit
    Offline

    Muqsit Active Member

    Joined:
    Sep 9, 2015
    Posts:
    175
    Minecraft User:
    Muqsit
    Thanks for the replies (OMG Intyre replied!!!) :D

    @Legoboy0215 :
    Well, PeMapModder had some supportive stuff to say about MySQL and MySQL Queries. Maybe because MySQL (obviously) runs parallel with PocketMine.
    SQLite3...well why not...but I'd go with MySQL because my future plan is to have a MySQL server running on a completely different system and PocketMine servers on another.
    XShockinFireX likes this.
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
  6. Muqsit
    Offline

    Muqsit Active Member

    Joined:
    Sep 9, 2015
    Posts:
    175
    Minecraft User:
    Muqsit
    Speaking of testing it out myself. I did test them out and there wasn't any huge difference between YAML and JSON (0.0001 diff, tried setting and getting 300 values in an array). I still have to test SQLite and MySQL.
  7. Muqsit
    Offline

    Muqsit Active Member

    Joined:
    Sep 9, 2015
    Posts:
    175
    Minecraft User:
    Muqsit
    Screenshot_2016-09-16-15-07-10.png
  8. Muqsit
    Offline

    Muqsit Active Member

    Joined:
    Sep 9, 2015
    Posts:
    175
    Minecraft User:
    Muqsit
    I'm focusing on performance btw.
    I'm the kind of guy who'd compile config.php into config.phar and use it as a config if that's gonna increase performance.
  9. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    For what? Player data?
    If so, a database (.db) or SQLite.
    also ah, .txt? it's not perfect :p
    and a .php is good too, using include, but not very good for users that don't know PHP.
    applqpak and Muqsit like this.
  10. Muqsit
    Offline

    Muqsit Active Member

    Joined:
    Sep 9, 2015
    Posts:
    175
    Minecraft User:
    Muqsit
    Ayee...nice reply!
    applqpak likes this.
  11. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I like MySQL and SQLite. Always use Async tasks to query, by the way.
    applqpak likes this.
  12. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    data*
    DAGA
    applqpak likes this.
  13. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    That doesn't matter if you don't read/save the file constantly on runtime.

    You usually cache the config to memory and use it as array. After you've done you're job, save the cache to config file and performance won't be trouble.
    PHP:
    private $config;

    // Load the config only once onEnable
    $this->config = new Config("config.file"Config::DETECT);
    // get the key
    $this->config->get("key");
    Instead of reloading the config everytime you use it
    PHP:
    (new Config("config.file"Config::DETECT))->get("key");
    Muqsit and applqpak like this.
  14. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    What about testing how fast what workss
    PHP:
    $beginTime microtime(true)
    //$cfg = new Config("config.TestAllVariants", Config::TestAllVariants)
    $cfg->save()
    $cfg->set(array("test" => 1"test2" => -19429));
    $cfg->save()
    $finalTime = - $beginTime microtime(true);
    echo(
    "Done! Took ".$finalTime."ms.");
    Last edited: Sep 18, 2016
  15. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Use microtime(true)
    applqpak and PocketKiller like this.
  16. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Oops, confusing because time() returns float/int
  17. Muqsit
    Offline

    Muqsit Active Member

    Joined:
    Sep 9, 2015
    Posts:
    175
    Minecraft User:
    Muqsit
    Thank you soo much primus. That's a REALLY good idea!
  18. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    there ambiguity here just because a plugin is big it doesn't mean it will take up a big config space
    BTW you can also use PHP sterilize SQLITE3 or just make your own config model (by exploding | as separator or something you can be creative)

Share This Page

Advertisement