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

Creating a simple config and saving data to it

Comments in 'Plugin Development' started by RekkuzaRage, May 3, 2015.

  1. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    How do I create a simple config and save data to the config? I been looking through plugins, but they use complicated methods. Ik there is many ways, but I want to know a simple way.
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    What do you want to save?
  3. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Save data, like a number. For example saving how many times a player breaks a block.
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Well, you can create a config.yml. There you can save something like an effect type which can be used at a playrr join. But you can also create Player files, like Steve.yml where you can save Stuff of a Player(like the broken Blocks). Of course you can also use other Databases like MySQL etc.
    Choose one of them^^
    RekkuzaRage likes this.
  5. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    PHP:
    $cfg = new Config($this->getDataFolder() . "myconfig.yml"Config::YAML);
    $cfg->set("number""1");
    $cfg->save();
    Taki21 and RekkuzaRage like this.
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Or use the default config. Of course you would have to create it in resources.
    PHP:
    $this->getConfig()->set("number",  "1");
    $this->getConfig()->save();
    But your way is faster.
    EvolSoft and RekkuzaRage like this.
  7. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Thank you for a straightforward answer.

Share This Page

Advertisement