getting custom config and saving inventory's to it.

Discussion in 'Plugin Development' started by OneBillionAndOne, Sep 4, 2013.

Thread Status:
Not open for further replies.
  1. Hello, today i am trying to create a new config called classes.yml In this config i want to save players inventory's (basically classes for my Ctf plugin) heres what ive got in onEnable;
    Code:java
    1. public void onEnable() {
    2. File config = new File(getDataFolder()+File.separator+"config.yml");
    3. File classes = new File(getDataFolder()+File.separator+"classes.yml");
    4. FileConfiguration classesconfig = YamlConfiguration.loadConfiguration(classes);
    5. classesconfig.getString("Path.To.String", "default");
    6.  
    7. if (!config.exists()){
    8. this.getLogger().info("Generating config.yml...");
    9. this.getConfig().options().copyDefaults(true);
    10. this.saveConfig();
    11. }
    12. if (!classes.exists()){
    13. this.getLogger().info("Generating classes.yml...");
    14. classesconfig.options().copyDefaults(true);
    15. try {
    16. classesconfig.save(classes);
    17. } catch (IOException e) {
    18. e.printStackTrace();
    19. }
    20. }

    (of course its not the full thing, cause my onEnable is big.)
    This seems to generate both files correctly.
    So then i want to in another class get that config and save inventory's to it.
    Thats where i have no idea what to do. Here is the code in the class i have that processes the command:
    Code:java
    1. public class classCreate implements CommandExecutor {
    2.  
    3. private CtfMain ctfmain;
    4.  
    5. public classCreate(CtfMain ctfmain) {
    6. this.ctfmain = ctfmain;
    7. }
    8.  
    9. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    10. if(cmd.getName().equalsIgnoreCase("setclass")){
    11. ctfmain.ctfclasses
    12. }
    13. return false;
    14.  
    15.  
    16. }
    17.  
    18. }
    19.  

    Any help appreciated, thanks!

    Bump. I gotta get help with this soon. thx.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  2. Offline

    mydeblob

Thread Status:
Not open for further replies.

Share This Page