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

Save data! and read it! Need Help ASAP

Comments in 'Plugin Development' started by Primus, Jun 28, 2015.

  1. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    All i wanna do is make a file for example
    And append more players in this way.
    Code:
    Primus: 2
    Steve: 1
    Bob: 0
    Notch: 0
    Enderman: 9
    
    and read it like in yaml
    PHP:
    ->get("Primus");
    but i wont use yaml cuz i read that using yaml for that purpose is not a good idea :D
  2. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Save it as a .txt file
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    And how to get value from it?
  4. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    The same as u would from a .yml file
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    Look like a got the solution :D
    CrazedMiner likes this.
  6. Pman1220
    Offline

    Pman1220 Active Member Plugin Developer

    Joined:
    Nov 21, 2013
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Pman1220
    if your saving it in your config.yml file use
    Code:
    $this->getConfig()->get("InsertHere");
    but as crazedminer said it would be more ideal to just use a txt file.
  7. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    it Dosent matter what extension u save the file as it's still classified as a config, the different file types are used for different things;
    .yml is used for editing to customise parts of a plugin
    .txt is used for being constantly written to internally
    iiDeathStrokeii and Legoboy0215 like this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You are wrong.
    .yml is a file extension for files containing data in format of an array / map (associative array) . It is not specific for containing configuration files and plugin manifest files. It has similar properties to JSON.

    As for .txt, it is for saving data with plaintext. It is also for files that you don't want to give a special file extension to.

    File extensions are used by the operating system (OS) to decide what apps to open the file with. But from a programming perspective, opening files of different file extensions, as long as they are files, have no difference. Why we call it file extension? Because it is an extension (and part of) the filename.

    Opening streams of different file extensions have no difference. You can even modify PocketMine source and change plugin.yml to plugin.txt, or make a config file of file extension .txt (see my old plugin InfoEssentials). (see MCPE for android; it saves its internal config files at ~/games/com.mojang/minecraftpe/*.txt)

    So basically, file extensions are just a way to let users to know what file type that file approximately is.
    64FF00 and CrazedMiner like this.
  9. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    This is true however, I like to use .yml files as files that will be edited by a person and .txt files for saving things internally that a person doesn't need to open as it saves internal things like stats.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Alright then. But you're saying it in a way that if you don't use the correct file extension it won't work.
    64FF00 and CrazedMiner like this.
  11. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    That's icky because if they do want to open and edit the stats, their IDE won't provide YML language support and there is a much higher likelihood of a syntax error.
    CrazedMiner likes this.

Share This Page

Advertisement