File Creation

Discussion in 'Plugin Development' started by Arcticmike, Apr 25, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Arcticmike

    Hello i am trying to create a file so i can store players data and other stuff fx: Players.yml
    please help
     
  2. Offline

    Flybelette

    Code:java
    1. File Playersfile = new File(plugin.getDataFolder().getPath(),"Players.yml");
    2. FileConfiguration players = YamlConfiguration.loadConfiguration(Playersfile);
    3. players.set("suffix", "[Example]");
    4. players.save(Playersfile);
     
  3. Offline

    Arcticmike

    Thanks it is working! :D
     
    Flybelette likes this.
  4. Offline

    Flybelette

    You'r welcome :)
     
  5. Offline

    stamline

    Can I also get some help on this tread?

    How can i get/set the config from another class. I cant get FileConfiguration rom the other class.
    I need to make it public
     
  6. Offline

    Wizehh

  7. Offline

    Arcticmike

    Make an instance of your other class and the do <Your other class instance>.<Your FileConfigurationName>.get(path)
     
  8. Offline

    stamline

    Arcticmike can you make a small code on that so I understand little more, thanks
     
  9. Offline

    Arcticmike

    In your main class do
    Code:java
    1. public final MyConfigClass mcc = new MyConfigClass(this);
    2.  
    3. @Override
    4. public void onEnable() {
    5. getServer().getPluginManager().registerEvents(mcc, this);
    6. }


    and on your other class you have to make your fileconfiguration public fx:
    Code:java
    1. public final FileConfiguration fc = YamlConfiguration.loadConfiguration(new File((File) plugin.getDatabase(), "Data.yml"));
    2.  



    and then now you can do
    Code:java
    1. FileConfiguration fc = mcc.fc.set("player", "arcticmike");
     
Thread Status:
Not open for further replies.

Share This Page